Class: Geocoder::Result::Ipbase

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/ipbase.rb

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Instance Method Summary collapse

Methods inherited from Base

#address, #initialize, #latitude, #longitude, #province, #province_code

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Instance Method Details

#cityObject



25
26
27
# File 'lib/geocoder/results/ipbase.rb', line 25

def city
  @data["data"]["location"]["city"]["name"]
end

#coordinatesObject



33
34
35
36
37
38
# File 'lib/geocoder/results/ipbase.rb', line 33

def coordinates
  [
    @data["data"]["location"]["latitude"].to_f,
    @data["data"]["location"]["longitude"].to_f
  ]
end

#countryObject



13
14
15
# File 'lib/geocoder/results/ipbase.rb', line 13

def country
  @data["data"]["location"]["country"]["name"]
end

#country_codeObject



9
10
11
# File 'lib/geocoder/results/ipbase.rb', line 9

def country_code
  @data["data"]["location"]["country"]["alpha2"]
end

#ipObject



5
6
7
# File 'lib/geocoder/results/ipbase.rb', line 5

def ip
  @data["data"]['ip']
end

#postal_codeObject



29
30
31
# File 'lib/geocoder/results/ipbase.rb', line 29

def postal_code
  @data["data"]["location"]["zip"]
end

#stateObject



21
22
23
# File 'lib/geocoder/results/ipbase.rb', line 21

def state
  @data["data"]["location"]["region"]["name"]
end

#state_codeObject



17
18
19
# File 'lib/geocoder/results/ipbase.rb', line 17

def state_code
  @data["data"]["location"]["region"]["alpha2"]
end