Class: Trackdown::LocationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/trackdown/location_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#cityObject (readonly)

Returns the value of attribute city.



7
8
9
# File 'lib/trackdown/location_result.rb', line 7

def city
  @city
end

#country_codeObject (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_nameObject (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_emojiObject (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_infoObject



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_hObject



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