Class: Genderize::Io::Base
- Inherits:
-
Object
- Object
- Genderize::Io::Base
- Defined in:
- lib/genderize/io/base.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_HOST =
'https://api.genderize.io'
- HEADER_KEYS =
%w[ x_rate_limit_limit x_rate_limit_remaining x_rate_reset ].freeze
Instance Attribute Summary collapse
-
#country_id ⇒ Object
readonly
Returns the value of attribute country_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#language_id ⇒ Object
readonly
Returns the value of attribute language_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, host: DEFAULT_HOST, country_id: nil, language_id: nil) ⇒ Base
constructor
A new instance of Base.
- #url ⇒ Object
Constructor Details
#initialize(name, host: DEFAULT_HOST, country_id: nil, language_id: nil) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 21 22 |
# File 'lib/genderize/io/base.rb', line 16 def initialize(name, host: DEFAULT_HOST, country_id: nil, language_id: nil) @name = name @host = host @country_id = country_id @language_id = language_id @request = nil end |
Instance Attribute Details
#country_id ⇒ Object (readonly)
Returns the value of attribute country_id.
14 15 16 |
# File 'lib/genderize/io/base.rb', line 14 def country_id @country_id end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/genderize/io/base.rb', line 14 def data @data end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/genderize/io/base.rb', line 14 def host @host end |
#language_id ⇒ Object (readonly)
Returns the value of attribute language_id.
14 15 16 |
# File 'lib/genderize/io/base.rb', line 14 def language_id @language_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/genderize/io/base.rb', line 14 def name @name end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
14 15 16 |
# File 'lib/genderize/io/base.rb', line 14 def request @request end |
Class Method Details
.determine(name, host: DEFAULT_HOST, country_id: nil, language_id: nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/genderize/io/base.rb', line 24 def self.determine(name, host: DEFAULT_HOST, country_id: nil, language_id: nil) instance = new(name, host: host, country_id: country_id, language_id: language_id) instance.determine instance end |
Instance Method Details
#url ⇒ Object
30 31 32 33 |
# File 'lib/genderize/io/base.rb', line 30 def url connector = @host.include?('?') ? '&' : '?' "#{@host}#{connector}#{param_name}#{param_country_id}#{param_language_id}" end |