Class: YandexDictionary::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/yandex_dictionary/api.rb

Constant Summary collapse

@@lang =
'en-en'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.api_key=(key) ⇒ Object



13
14
15
# File 'lib/yandex_dictionary/api.rb', line 13

def self.api_key= key
  @@api_key = key
end

.lang=(lang) ⇒ Object



17
18
19
# File 'lib/yandex_dictionary/api.rb', line 17

def self.lang= lang
  @@lang = lang
end

Instance Method Details

#getLangsObject

Returns a list of language supported by the server



22
23
24
25
# File 'lib/yandex_dictionary/api.rb', line 22

def getLangs
  result = self.class.get '/getLangs', { query:{ key:@@api_key } }
  check_result result
end

#lookup(text) ⇒ Object

Searches for words or phrases in the dictionary and returns an automatically generated dictionary entry



28
29
30
31
# File 'lib/yandex_dictionary/api.rb', line 28

def lookup text
  result = self.class.get '/lookup', { query:{ key:@@api_key, lang:@@lang, text:text } }
  check_result result  
end