Class: Geocoder::Result::Opencagedata
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Opencagedata
show all
- Defined in:
- lib/geocoder/results/opencagedata.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
69
70
71
72
|
# File 'lib/geocoder/results/opencagedata.rb', line 69
def self.response_attributes
%w[boundingbox license
formatted stadium]
end
|
Instance Method Details
#address ⇒ Object
17
18
19
|
# File 'lib/geocoder/results/opencagedata.rb', line 17
def address
@data['formatted']
end
|
#city ⇒ Object
28
29
30
31
32
33
|
# File 'lib/geocoder/results/opencagedata.rb', line 28
def city
%w[city town village hamlet].each do |key|
return @data['components'][key] if @data['components'].key?(key)
end
return nil
end
|
#coordinates ⇒ Object
66
67
68
|
# File 'lib/geocoder/results/opencagedata.rb', line 66
def coordinates
[@data['geometry']['lat'].to_f, @data['geometry']['lng'].to_f]
end
|
#country ⇒ Object
54
55
56
|
# File 'lib/geocoder/results/opencagedata.rb', line 54
def country
@data['components']['country']
end
|
#country_code ⇒ Object
58
59
60
|
# File 'lib/geocoder/results/opencagedata.rb', line 58
def country_code
@data['components']['country_code']
end
|
#county ⇒ Object
50
51
52
|
# File 'lib/geocoder/results/opencagedata.rb', line 50
def county
@data['components']['county']
end
|
#house_number ⇒ Object
13
14
15
|
# File 'lib/geocoder/results/opencagedata.rb', line 13
def house_number
@data['components']['house_number']
end
|
#poi ⇒ Object
6
7
8
9
10
11
|
# File 'lib/geocoder/results/opencagedata.rb', line 6
def poi
%w[stadium bus_stop tram_stop].each do |key|
return @data['components'][key] if @data['components'].key?(key)
end
return nil
end
|
#postal_code ⇒ Object
46
47
48
|
# File 'lib/geocoder/results/opencagedata.rb', line 46
def postal_code
@data['components']['postcode'].to_s
end
|
#state ⇒ Object
Also known as:
state_code
40
41
42
|
# File 'lib/geocoder/results/opencagedata.rb', line 40
def state
@data['components']['state']
end
|
#street ⇒ Object
21
22
23
24
25
26
|
# File 'lib/geocoder/results/opencagedata.rb', line 21
def street
%w[road pedestrian highway].each do |key|
return @data['components'][key] if @data['components'].key?(key)
end
return nil
end
|
#suburb ⇒ Object
62
63
64
|
# File 'lib/geocoder/results/opencagedata.rb', line 62
def suburb
@data['components']['suburb']
end
|
#village ⇒ Object
35
36
37
|
# File 'lib/geocoder/results/opencagedata.rb', line 35
def village
@data['components']['village']
end
|