Class: Trackdown::LocationResult
- Inherits:
-
Object
- Object
- Trackdown::LocationResult
- Defined in:
- lib/trackdown/location_result.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country_code ⇒ Object
readonly
Returns the value of attribute country_code.
-
#country_name ⇒ Object
(also: #country)
readonly
Returns the value of attribute country_name.
-
#flag_emoji ⇒ Object
(also: #emoji, #emoji_flag, #country_flag)
readonly
Returns the value of attribute flag_emoji.
Instance Method Summary collapse
- #country_info ⇒ Object
-
#initialize(country_code, country_name, city, flag_emoji) ⇒ LocationResult
constructor
A new instance of LocationResult.
- #to_h ⇒ Object
Constructor Details
#initialize(country_code, country_name, city, flag_emoji) ⇒ LocationResult
Returns a new instance of LocationResult.
9 10 11 12 13 14 |
# File 'lib/trackdown/location_result.rb', line 9 def initialize(country_code, country_name, city, flag_emoji) @country_code = country_code @country_name = country_name @city = city @flag_emoji = flag_emoji end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
7 8 9 |
# File 'lib/trackdown/location_result.rb', line 7 def city @city end |
#country_code ⇒ Object (readonly)
Returns the value of attribute country_code.
7 8 9 |
# File 'lib/trackdown/location_result.rb', line 7 def country_code @country_code end |
#country_name ⇒ Object (readonly) Also known as: country
Returns the value of attribute country_name.
7 8 9 |
# File 'lib/trackdown/location_result.rb', line 7 def country_name @country_name end |
#flag_emoji ⇒ Object (readonly) Also known as: emoji, emoji_flag, country_flag
Returns the value of attribute flag_emoji.
7 8 9 |
# File 'lib/trackdown/location_result.rb', line 7 def flag_emoji @flag_emoji end |
Instance Method Details
#country_info ⇒ Object
21 22 23 24 |
# File 'lib/trackdown/location_result.rb', line 21 def country_info return nil unless country_code ISO3166::Country.new(country_code) end |
#to_h ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/trackdown/location_result.rb', line 26 def to_h { country_code: @country_code, country_name: @country_name, city: @city, flag_emoji: @flag_emoji, country_info: country_info&.data || {} } end |