Module: Wordwiki

Included in:
CLI
Defined in:
lib/wordwiki.rb,
lib/wordwiki/cli.rb,
lib/wordwiki/version.rb,
lib/wordwiki/constants.rb

Defined Under Namespace

Classes: CLI

Constant Summary collapse

VERSION =
'0.2.3'.freeze
FREE_DICTIONARY_URL =
"https://api.dictionaryapi.dev/api/v2/entries/en/".freeze

Instance Method Summary collapse

Instance Method Details

#definition(word) ⇒ Object

Implements define functionality



12
13
14
15
16
17
# File 'lib/wordwiki.rb', line 12

def definition(word)
  url = FREE_DICTIONARY_URL + ERB::Util.url_encode(word)
  response = Faraday.get(url)
  return error_response(response) unless response.success?
  format_definition(response.body)
end