Sha256: 63841a3c2ec203260bf29672e27f77eda39177ce26e63387144a39d249eccfbf

Contents?: true

Size: 813 Bytes

Versions: 3

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module Genderize
  module Io
    class Lookup < Genderize::Io::Base

      RESPONSE_KEYS ||= %w[count country_id error language_id gender probability].freeze

      def initialize(name, host: DEFAULT_HOST, country_id: nil, language_id: nil)
        super(name, host: host, country_id: country_id, language_id: language_id)
        @data = {}
      end

      def determine
        return @data unless @request.nil?

        @request = generate_request
        @data = generate_data.merge(generate_rate_limits)
      end

      HEADER_KEYS.each do |key|
        define_method(key) { @data[key] }
      end

      RESPONSE_KEYS.each do |key|
        define_method(key) { @data[key] }
      end

      private

      def param_name
        "name=#{@name}"
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
genderize-io-1.1.0 lib/genderize/io/lookup.rb
genderize-io-1.0.1 lib/genderize/io/lookup.rb
genderize-io-1.0.0 lib/genderize/io/lookup.rb