Method: FreeDictionaryApi::Client#lookup!

Defined in:
lib/free_dictionary_api.rb

#lookup!(word) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/free_dictionary_api.rb', line 35

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, true)
  end
end