Class: DictionaryAPI::DictionaryAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/dictionary_api.rb

Defined Under Namespace

Classes: Client, Parser

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject

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_langsObject



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