Sha256: 4525ae8b67802109b521e95556f73b505d1b9a509f5b82b309fdf9d6136dcfc8
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# -*- coding: utf-8 -*- require 'dict/wiktionary' require 'dict/dictpl' require 'json' module Dict class << self def get_all_dictionaries_translations(word) dictionaries = Hash.new available_services.each do |service| dictionaries[service] = get_single_dictionary_translations(word, service) end dictionaries end def print_all_dictionaries_translations(word) end def get_single_dictionary_translations(word, service) case service when 'wiktionary' Wiktionary.new(word, WIKI_URL).translate when 'dictpl' Dictpl.new(word, DICT_URL).translate else Dictionary.message end rescue Dictionary::ConnectError "Couldn't connect to the service." end def print_single_dictionary_translations(word, service) obj = get_single_dictionary_translations(word, service) hash = obj.translate hash.each do |k, v| puts "#{k} - #{v}" end end def to_json(hash) hash.to_json end def available_services ['wiktionary', 'dictpl'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dict-0.2.1 | lib/dict/dict.rb |