Class: Geocoder::Result::Baidu
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::Baidu
show all
- Defined in:
- lib/geocoder/results/baidu.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_code
Class Method Details
.response_attributes ⇒ Object
Get address components of a given type. Valid types are defined in Baidu’s Geocoding API documentation and include (among others):
:business
:cityCode
65
66
67
|
# File 'lib/geocoder/results/baidu.rb', line 65
def self.response_attributes
%w[business cityCode]
end
|
Instance Method Details
#address_components ⇒ Object
38
39
40
|
# File 'lib/geocoder/results/baidu.rb', line 38
def address_components
@data['addressComponent']
end
|
#city ⇒ Object
16
17
18
|
# File 'lib/geocoder/results/baidu.rb', line 16
def city
@data['addressComponent'] and @data['addressComponent']['city'] or ""
end
|
#coordinates ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/baidu.rb', line 6
def coordinates
['lat', 'lng'].map{ |i| @data['location'][i] }
end
|
#country ⇒ Object
50
51
52
|
# File 'lib/geocoder/results/baidu.rb', line 50
def country
"China"
end
|
#country_code ⇒ Object
54
55
56
|
# File 'lib/geocoder/results/baidu.rb', line 54
def country_code
"CN"
end
|
#district ⇒ Object
20
21
22
|
# File 'lib/geocoder/results/baidu.rb', line 20
def district
@data['addressComponent'] and @data['addressComponent']['district'] or ""
end
|
32
33
34
|
# File 'lib/geocoder/results/baidu.rb', line 32
def formatted_address
@data['formatted_address'] or ""
end
|
#postal_code ⇒ Object
46
47
48
|
# File 'lib/geocoder/results/baidu.rb', line 46
def postal_code
""
end
|
#province ⇒ Object
Also known as:
state
10
11
12
|
# File 'lib/geocoder/results/baidu.rb', line 10
def province
@data['addressComponent'] and @data['addressComponent']['province'] or ""
end
|
#state_code ⇒ Object
42
43
44
|
# File 'lib/geocoder/results/baidu.rb', line 42
def state_code
""
end
|
#street ⇒ Object
24
25
26
|
# File 'lib/geocoder/results/baidu.rb', line 24
def street
@data['addressComponent'] and @data['addressComponent']['street'] or ""
end
|
#street_number ⇒ Object
28
29
30
|
# File 'lib/geocoder/results/baidu.rb', line 28
def street_number
@data['addressComponent'] and @data['addressComponent']['street_number']
end
|