Class: Geocoder::Result::Geocodio
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Geocodio
show all
- Defined in:
- lib/geocoder/results/geocodio.rb
Instance Attribute Summary
Attributes inherited from Base
#cache_hit, #data
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude, #province, #province_code
Instance Method Details
#accuracy ⇒ Object
63
64
65
|
# File 'lib/geocoder/results/geocodio.rb', line 63
def accuracy
@data['accuracy'].to_f if @data.key?('accuracy')
end
|
#city ⇒ Object
47
48
49
|
# File 'lib/geocoder/results/geocodio.rb', line 47
def city
address_components["city"]
end
|
#coordinates ⇒ Object
59
60
61
|
# File 'lib/geocoder/results/geocodio.rb', line 59
def coordinates
['lat', 'lng'].map{ |i| location[i].to_f } if location
end
|
#country ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/geocoder/results/geocodio.rb', line 32
def country
if country_code == "CA"
"Canada"
else
"United States"
end
end
|
#country_code ⇒ Object
43
44
45
|
# File 'lib/geocoder/results/geocodio.rb', line 43
def country_code
address_components['country']
end
|
67
68
69
|
# File 'lib/geocoder/results/geocodio.rb', line 67
def formatted_address(format = :full)
@data['formatted_address']
end
|
#location ⇒ Object
55
56
57
|
# File 'lib/geocoder/results/geocodio.rb', line 55
def location
@data['location']
end
|
#number ⇒ Object
5
6
7
|
# File 'lib/geocoder/results/geocodio.rb', line 5
def number
address_components["number"]
end
|
#postdirectional ⇒ Object
51
52
53
|
# File 'lib/geocoder/results/geocodio.rb', line 51
def postdirectional
address_components["postdirectional"]
end
|
#state ⇒ Object
Also known as:
state_code
21
22
23
|
# File 'lib/geocoder/results/geocodio.rb', line 21
def state
address_components["state"]
end
|
#street ⇒ Object
9
10
11
|
# File 'lib/geocoder/results/geocodio.rb', line 9
def street
address_components["street"]
end
|
#street_address ⇒ Object
17
18
19
|
# File 'lib/geocoder/results/geocodio.rb', line 17
def street_address
[number, address_components["formatted_street"]].compact.join(' ')
end
|
#suffix ⇒ Object
13
14
15
|
# File 'lib/geocoder/results/geocodio.rb', line 13
def suffix
address_components["suffix"]
end
|
#zip ⇒ Object
Also known as:
postal_code
26
27
28
29
|
# File 'lib/geocoder/results/geocodio.rb', line 26
def zip
address_components["zip"] || ""
end
|