Class: DictionaryAPI::DictionaryAPI
- Inherits:
-
Object
- Object
- DictionaryAPI::DictionaryAPI
- Defined in:
- lib/dictionary_api.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
- #get_langs ⇒ Object
-
#initialize(key) ⇒ DictionaryAPI
constructor
A new instance of DictionaryAPI.
- #lookup(lang, text) ⇒ Object
Constructor Details
#initialize(key) ⇒ DictionaryAPI
Returns a new instance of DictionaryAPI.
11 12 13 |
# File 'lib/dictionary_api.rb', line 11 def initialize(key) @api_key = key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/dictionary_api.rb', line 9 def api_key @api_key end |
Instance Method Details
#get_langs ⇒ Object
15 16 17 |
# File 'lib/dictionary_api.rb', line 15 def get_langs JSON.parse client.execute('getLangs').body end |
#lookup(lang, text) ⇒ Object
19 20 21 22 |
# File 'lib/dictionary_api.rb', line 19 def lookup(lang, text) response = JSON.parse client.execute('lookup', {key: @api_key, lang: lang, text: text}).body parser.parse(response) end |