Class: JustimmoClient::V1::Country
Instance Method Summary
collapse
#==, #save!
Methods included from Utils
#autoload_dir, #translate
Methods included from Logging
default_logger, #logger, rails_logger
Constructor Details
#initialize(**options) ⇒ Country
Returns a new instance of Country.
18
19
20
21
22
23
24
25
26
|
# 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
|
Instance Method Details
#alpha2 ⇒ String
12
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 12
attribute :alpha2, String, default: ""
|
#alpha2=(code) ⇒ Object
28
29
30
31
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 28
def alpha2=(code)
find_country(code)
@alpha2 ||= @country&.alpha2
end
|
#alpha3 ⇒ String
13
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 13
attribute :alpha3, String, default: ""
|
#alpha3=(code) ⇒ Object
33
34
35
36
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 33
def alpha3=(code)
find_country(code)
@alpha3 ||= @country&.alpha3
end
|
#id ⇒ Integer
11
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 11
attribute :id, Integer
|
#inspect ⇒ Object
57
58
59
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 57
def inspect
"#<#{self.class} #{self}>"
end
|
#name ⇒ String
14
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 14
attribute :name, String, default: ""
|
#name=(country_name) ⇒ Object
38
39
40
41
|
# 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 ⇒ Object
47
48
49
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 47
def to_h
attributes
end
|
#to_json(options = nil) ⇒ Object
Also known as:
as_json
51
52
53
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 51
def to_json(options = nil)
to_h.to_json(options)
end
|
#to_s ⇒ Object
43
44
45
|
# File 'lib/justimmo_client/api/v1/models/country.rb', line 43
def to_s
name
end
|