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
42
43
44
|
# File 'lib/geocoder/results/mapbox.rb', line 42
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
@data['context'].map { |c| c['text'] if c['id'] =~ /place/ }.compact.first
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
Also known as:
country_code
32
33
34
|
# File 'lib/geocoder/results/mapbox.rb', line 32
def country
@data['context'].map { |c| c['text'] if c['id'] =~ /country/ }.compact.first
end
|
#neighborhood ⇒ Object
38
39
40
|
# File 'lib/geocoder/results/mapbox.rb', line 38
def neighborhood
@data['context'].map { |c| c['text'] if c['id'] =~ /neighborhood/ }.compact.first
end
|
#place_name ⇒ Object
10
11
12
|
# File 'lib/geocoder/results/mapbox.rb', line 10
def place_name
@data['text']
end
|
#postal_code ⇒ Object
28
29
30
|
# File 'lib/geocoder/results/mapbox.rb', line 28
def postal_code
@data['context'].map { |c| c['text'] if c['id'] =~ /postcode/ }.compact.first
end
|
#state ⇒ Object
Also known as:
state_code
22
23
24
|
# File 'lib/geocoder/results/mapbox.rb', line 22
def state
@data['context'].map { |c| c['text'] if c['id'] =~ /region/ }.compact.first
end
|
#street ⇒ Object
14
15
16
|
# File 'lib/geocoder/results/mapbox.rb', line 14
def street
@data['properties']['address']
end
|