Class: OxfordDictionary::Endpoints::Lemmas

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/oxford_dictionary/endpoints/lemmas.rb

Overview

Interface for the /lemmas endpoint

API documentation can be found here: developer.oxforddictionaries.com/documentation

Constant Summary collapse

ENDPOINT =
'lemmas'.freeze

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

This class inherits a constructor from OxfordDictionary::Endpoints::Endpoint

Instance Method Details

#lemma(word:, language:, params: {}) ⇒ OpenStruct

Returns all possible lemmas for a word

Examples:

Search for the verb lemmas of ‘running’ in ‘en’

lemma(
  word: 'running',
  language: 'en',
  params: { lexicalCategory: 'verb' }
)

Parameters:

  • word (String)

    the inflected word to search for

  • language (String)

    the language to search in

  • params (Hash) (defaults to: {})

    the query parameters in the request

Returns:

  • (OpenStruct)

    the JSON response parsed into an OpenStruct



26
27
28
29
30
31
32
# File 'lib/oxford_dictionary/endpoints/lemmas.rb', line 26

def lemma(word:, language:, params: {})
  path = "#{ENDPOINT}/#{language}/#{word}"
  uri = request_uri(path: path, params: params)

  response = @request_client.get(uri: uri)
  deserialize.call(response.body)
end