Module: Dict
- Defined in:
- lib/dict.rb,
lib/dict/dict.rb,
lib/dict/glosbe.rb,
lib/dict/result.rb,
lib/dict/version.rb,
lib/dict/cli/runner.rb,
lib/dict/dictionary.rb,
lib/dict/wiktionary.rb
Defined Under Namespace
Modules: CLI Classes: Dictionary, Glosbe, Result, Wiktionary
Constant Summary collapse
- VERSION =
"0.3.7"
Class Method Summary collapse
-
.available_dictionaries ⇒ Object
Returns array of currently available dictionaries.
-
.get_all_dictionaries_translations(word) ⇒ Object
Returns hash with structure as showed below { ‘DICTIONARY_NAME’ => { ‘TRANSLATION’ => [‘EXAMPLE’, …], … }, … }.
-
.get_single_dictionary_translations(word, dictionary) ⇒ Object
Returns hash with structure as showed below { ‘TRANSLATION’ => [‘EXAMPLE’, …], … }.
Class Method Details
.available_dictionaries ⇒ Object
Returns array of currently available dictionaries.
32 33 34 |
# File 'lib/dict/dict.rb', line 32 def available_dictionaries ['wiktionary', 'glosbe'] end |
.get_all_dictionaries_translations(word) ⇒ Object
Returns hash with structure as showed below { ‘DICTIONARY_NAME’ => { ‘TRANSLATION’ => [‘EXAMPLE’, …], … }, … }
12 13 14 15 16 17 18 19 |
# File 'lib/dict/dict.rb', line 12 def get_all_dictionaries_translations(word) dictionaries = Hash.new available_dictionaries.each do |dictionary| dictionaries[dictionary] = get_single_dictionary_translations(word, dictionary) end dictionaries end |
.get_single_dictionary_translations(word, dictionary) ⇒ Object
Returns hash with structure as showed below { ‘TRANSLATION’ => [‘EXAMPLE’, …], … }
23 24 25 26 27 28 29 |
# File 'lib/dict/dict.rb', line 23 def get_single_dictionary_translations(word, dictionary) if available_dictionaries.include? dictionary Dict.const_get(dictionary.capitalize).new(word).translate.translations else Dictionary. end end |