Sha256: 685c4850b1796cbc3e05ebea069e1c9878bc216075d2034300c3e3e88aaf492f
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# -*- coding: utf-8 -*- require 'dict/wiktionary' require 'dict/glosbe' require "yaml" module Dict class << self # Returns hash with structure as showed below # { 'DICTIONARY_NAME' => { 'TRANSLATION' => ['EXAMPLE', ...], ... }, ... } 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 # Returns hash with structure as showed below # { 'TRANSLATION' => ['EXAMPLE', ...], ... } def get_single_dictionary_translations(word, dictionary) case dictionary when 'wiktionary' Wiktionary.new(word).translate.translations when 'glosbe' Glosbe.new(word).translate.translations else Dictionary.message end rescue Dictionary::ConnectError "Couldn't connect to the dictionary." end # Returns array of currently available dictionaries. def available_dictionaries ['wiktionary', 'glosbe'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dict-0.3.4 | lib/dict/dict.rb |