Method: FreeDictionaryApi::Client#lookup

Defined in:
lib/free_dictionary_api.rb

#lookup(word) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/free_dictionary_api.rb', line 22

def lookup(word)
  encoded_word = PARSER.escape(word)
  uri = URI("#{BASE_URL}/#{encoded_word}")
  response = Net::HTTP.get_response(uri)

  case response
  when Net::HTTPSuccess
    parse_response(response.body)
  else
    handle_error(response)
  end
end