Class: IPGeo::Result
- Inherits:
-
Object
- Object
- IPGeo::Result
- Defined in:
- lib/ip_geo/result.rb
Constant Summary collapse
- EU_COUNTRY_CODES =
["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GB", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"].freeze
Instance Method Summary collapse
- #city ⇒ Object
- #country ⇒ Object
- #country_name ⇒ Object
- #eu? ⇒ Boolean
- #geoname_id ⇒ Object
-
#initialize(hash) ⇒ Result
constructor
A new instance of Result.
- #latitude ⇒ Object
- #longitude ⇒ Object
Constructor Details
#initialize(hash) ⇒ Result
Returns a new instance of Result.
8 9 10 |
# File 'lib/ip_geo/result.rb', line 8 def initialize(hash) @hash = hash end |
Instance Method Details
#city ⇒ Object
20 21 22 |
# File 'lib/ip_geo/result.rb', line 20 def city @hash['city'] end |
#country ⇒ Object
12 13 14 |
# File 'lib/ip_geo/result.rb', line 12 def country @hash['country'] end |
#country_name ⇒ Object
16 17 18 |
# File 'lib/ip_geo/result.rb', line 16 def country_name @hash['country_name'] end |
#eu? ⇒ Boolean
36 37 38 |
# File 'lib/ip_geo/result.rb', line 36 def eu? EU_COUNTRY_CODES.include?(country) end |
#geoname_id ⇒ Object
32 33 34 |
# File 'lib/ip_geo/result.rb', line 32 def geoname_id @hash['geoname_id'] end |
#latitude ⇒ Object
24 25 26 |
# File 'lib/ip_geo/result.rb', line 24 def latitude @hash['latitude'] end |
#longitude ⇒ Object
28 29 30 |
# File 'lib/ip_geo/result.rb', line 28 def longitude @hash['longitude'] end |