class JustimmoClient::V1::Country
Public Class Methods
new(**options)
click to toggle source
@!group Instance Method Summary
Calls superclass method
# File lib/justimmo_client/api/v1/models/country.rb, line 18 def initialize(**options) super(options) find_country(options[:name]) find_country(options[:alpha3]) find_country(options[:alpha2]) @name = @country&.name @alpha3 = @country&.alpha3 @alpha2 = @country&.alpha2 end
Public Instance Methods
alpha2=(code)
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 28 def alpha2=(code) find_country(code) @alpha2 ||= @country&.alpha2 end
alpha3=(code)
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 33 def alpha3=(code) find_country(code) @alpha3 ||= @country&.alpha3 end
inspect()
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 57 def inspect "#<#{self.class} #{self}>" end
name=(country_name)
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 38 def name=(country_name) find_country(country_name) @name ||= @country&.name end
to_h()
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 47 def to_h attributes end
to_json(options = nil)
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 51 def to_json(options = nil) to_h.to_json(options) end
Also aliased as: as_json
to_s()
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 43 def to_s name end
Private Instance Methods
find_country(name_or_code)
click to toggle source
# File lib/justimmo_client/api/v1/models/country.rb, line 63 def find_country(name_or_code) return if name_or_code.nil? @country ||= if name_or_code.size <= 3 IsoCountryCodes.find(name_or_code) else IsoCountryCodes.search_by_name(name_or_code).first end rescue IsoCountryCodes::UnknownCodeError nil end