Class: Vocabulary::Dictionary
- Inherits:
-
Object
- Object
- Vocabulary::Dictionary
- Includes:
- HTTParty
- Defined in:
- lib/vocabulary.rb
Instance Method Summary collapse
Instance Method Details
#get(word, source_lang, target_lang) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vocabulary.rb', line 24 def get(word, source_lang, target_lang) # example request # /dictionary/json?callback=substr&q=apple&sl=en&tl=en&restrict=pr%2Cde&client=te = {} [:query] = { :callback => "substr", :q => word, :sl => target_lang, :tl => source_lang } response = self.class.get("/dictionary/json", ) if response info = response.parsed_response json = info.gsub("substr(", "").gsub!(",200,null)", "") JSON.parse(json) end end |