Class: Geocoder::Result::IpinfoIo
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::IpinfoIo
show all
- Defined in:
- lib/geocoder/results/ipinfo_io.rb
Instance Attribute Summary
Attributes inherited from Base
#cache_hit, #data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude, #province, #province_code
Class Method Details
.response_attributes ⇒ Object
38
39
40
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 38
def self.response_attributes
%w(ip region postal)
end
|
Instance Method Details
#address(format = :full) ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 6
def address(format = :full)
"#{city} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
end
|
#city ⇒ Object
14
15
16
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 14
def city
@data['city']
end
|
#coordinates ⇒ Object
10
11
12
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 10
def coordinates
@data['loc'].to_s.split(",").map(&:to_f)
end
|
#country ⇒ Object
22
23
24
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 22
def country
@data['country']
end
|
#country_code ⇒ Object
30
31
32
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 30
def country_code
@data.fetch('country', '')
end
|
#postal_code ⇒ Object
26
27
28
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 26
def postal_code
@data['postal']
end
|
#state ⇒ Object
18
19
20
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 18
def state
@data['region']
end
|
#state_code ⇒ Object
34
35
36
|
# File 'lib/geocoder/results/ipinfo_io.rb', line 34
def state_code
@data.fetch('region_code', '')
end
|