Class: YandexDictionaryApi::ApiInterface
- Inherits:
-
Object
- Object
- YandexDictionaryApi::ApiInterface
- Defined in:
- lib/yandex_dictionary_api.rb
Instance Method Summary collapse
-
#get_langs ⇒ Object
Executes getLangs (list of supported languages) request to YandexDictionaryApi api.
-
#initialize(api_key) ⇒ ApiInterface
constructor
A new instance of ApiInterface.
-
#lookup(params_hash) ⇒ Object
Executes lookup (Interpretation and translate) request to yandex dictionary api Returns Json object (see Readme example).
-
#lookup_arr(params_hash) ⇒ Object
Executes lookup (Interpretation and translate) request to yandex dictionary api Returns Array of Articles (see Readme example).
Constructor Details
#initialize(api_key) ⇒ ApiInterface
Returns a new instance of ApiInterface.
11 12 13 |
# File 'lib/yandex_dictionary_api.rb', line 11 def initialize(api_key) @client = YandexDictionaryApi::ApiClient.new(api_key) end |
Instance Method Details
#get_langs ⇒ Object
Executes getLangs (list of supported languages) request to YandexDictionaryApi api
16 17 18 19 20 |
# File 'lib/yandex_dictionary_api.rb', line 16 def get_langs response = @client.execute("getLangs", Hash.new) self.check_response(response) JSON.parse(response.body) end |
#lookup(params_hash) ⇒ Object
Executes lookup (Interpretation and translate) request to yandex dictionary api Returns Json object (see Readme example).
24 25 26 27 |
# File 'lib/yandex_dictionary_api.rb', line 24 def lookup(params_hash) response = exec_lookup(params_hash) JSON.parse(response.body) end |
#lookup_arr(params_hash) ⇒ Object
Executes lookup (Interpretation and translate) request to yandex dictionary api Returns Array of Articles (see Readme example).
31 32 33 34 |
# File 'lib/yandex_dictionary_api.rb', line 31 def lookup_arr(params_hash) response = exec_lookup(params_hash) read_lookup_response(JSON.parse(response.body)) end |