Sha256: 71390e1c2422f17ced8a198b343e565b959813e9f024bb861dc6381570d21e61

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

require 'oxford_dictionary/deserialize'

module OxfordDictionary
  module Endpoints
    class Lemmas
      ENDPOINT = 'lemmas'.freeze

      def initialize(request_client:)
        @request_client = request_client
      end

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

        unless params.empty?
          uri.query = URI.encode_www_form(params)
        end

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

      private

      def deserialize
        @deserialize ||= OxfordDictionary::Deserialize.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oxford_dictionary-1.2.0 lib/oxford_dictionary/endpoints/lemmas.rb