Class: IPGeo::Result

Inherits:
Object
  • Object
show all
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

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

#cityObject



20
21
22
# File 'lib/ip_geo/result.rb', line 20

def city
  @hash['city']
end

#countryObject



12
13
14
# File 'lib/ip_geo/result.rb', line 12

def country
  @hash['country']
end

#country_nameObject



16
17
18
# File 'lib/ip_geo/result.rb', line 16

def country_name
  @hash['country_name']
end

#eu?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/ip_geo/result.rb', line 36

def eu?
  EU_COUNTRY_CODES.include?(country)
end

#geoname_idObject



32
33
34
# File 'lib/ip_geo/result.rb', line 32

def geoname_id
  @hash['geoname_id']
end

#latitudeObject



24
25
26
# File 'lib/ip_geo/result.rb', line 24

def latitude
  @hash['latitude']
end

#longitudeObject



28
29
30
# File 'lib/ip_geo/result.rb', line 28

def longitude
  @hash['longitude']
end