Class: Geocoder::Result::Mapbox
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Mapbox
show all
- Defined in:
- lib/geocoder/results/mapbox.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
#address ⇒ Object
48
49
50
|
# File 'lib/geocoder/results/mapbox.rb', line 48
def address
[place_name, street, city, state, postal_code, country].compact.join(', ')
end
|
#city ⇒ Object
18
19
20
|
# File 'lib/geocoder/results/mapbox.rb', line 18
def city
context_part('place')
end
|
#coordinates ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/mapbox.rb', line 6
def coordinates
data['geometry']['coordinates'].reverse.map(&:to_f)
end
|
#country ⇒ Object
35
36
37
|
# File 'lib/geocoder/results/mapbox.rb', line 35
def country
context_part('country')
end
|
#country_code ⇒ Object
39
40
41
42
|
# File 'lib/geocoder/results/mapbox.rb', line 39
def country_code
value = context_part('country', 'short_code')
value.upcase unless value.nil?
end
|
#neighborhood ⇒ Object
44
45
46
|
# File 'lib/geocoder/results/mapbox.rb', line 44
def neighborhood
context_part('neighborhood')
end
|
#place_name ⇒ Object
10
11
12
|
# File 'lib/geocoder/results/mapbox.rb', line 10
def place_name
data['text']
end
|
#postal_code ⇒ Object
31
32
33
|
# File 'lib/geocoder/results/mapbox.rb', line 31
def postal_code
context_part('postcode')
end
|
#state ⇒ Object
22
23
24
|
# File 'lib/geocoder/results/mapbox.rb', line 22
def state
context_part('region')
end
|
#state_code ⇒ Object
26
27
28
29
|
# File 'lib/geocoder/results/mapbox.rb', line 26
def state_code
value = context_part('region', 'short_code')
value.split('-').last unless value.nil?
end
|
#street ⇒ Object
14
15
16
|
# File 'lib/geocoder/results/mapbox.rb', line 14
def street
data['properties']['address']
end
|