dusty-geocoder 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/geocoder.rb +1 -1
- data/lib/geocoder/response.rb +12 -9
- metadata +1 -1
data/lib/geocoder.rb
CHANGED
data/lib/geocoder/response.rb
CHANGED
@@ -73,7 +73,7 @@ module Geocoder
|
|
73
73
|
# @return [String] street
|
74
74
|
def street
|
75
75
|
@street ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\
|
76
|
-
|
76
|
+
["Locality"]["Thoroughfare"]["ThoroughfareName"] rescue nil
|
77
77
|
end
|
78
78
|
|
79
79
|
##
|
@@ -82,7 +82,7 @@ module Geocoder
|
|
82
82
|
# @return [String] city
|
83
83
|
def city
|
84
84
|
@city ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\
|
85
|
-
|
85
|
+
["Locality"]["LocalityName"] rescue nil
|
86
86
|
end
|
87
87
|
|
88
88
|
##
|
@@ -91,7 +91,7 @@ module Geocoder
|
|
91
91
|
# @return [String] state
|
92
92
|
def state
|
93
93
|
@state ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\
|
94
|
-
|
94
|
+
["AdministrativeAreaName"] rescue nil
|
95
95
|
end
|
96
96
|
|
97
97
|
##
|
@@ -100,7 +100,7 @@ module Geocoder
|
|
100
100
|
# @return [String] zipcode
|
101
101
|
def zipcode
|
102
102
|
@zipcode ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\
|
103
|
-
|
103
|
+
["Locality"]["PostalCode"]["PostalCodeNumber"] rescue nil
|
104
104
|
end
|
105
105
|
|
106
106
|
##
|
@@ -108,7 +108,8 @@ module Geocoder
|
|
108
108
|
#
|
109
109
|
# @return [String] country
|
110
110
|
def country
|
111
|
-
@country ||= @hash["AddressDetails"]["Country"]["CountryNameCode"]
|
111
|
+
@country ||= @hash["AddressDetails"]["Country"]["CountryNameCode"]\
|
112
|
+
rescue nil
|
112
113
|
end
|
113
114
|
|
114
115
|
##
|
@@ -120,7 +121,8 @@ module Geocoder
|
|
120
121
|
# @see accuracy_map
|
121
122
|
# @return [String] accuracy
|
122
123
|
def accuracy
|
123
|
-
@accuracy ||= accuracy_map[@hash["AddressDetails"]["Accuracy"].to_i]
|
124
|
+
@accuracy ||= accuracy_map[@hash["AddressDetails"]["Accuracy"].to_i]\
|
125
|
+
rescue nil
|
124
126
|
end
|
125
127
|
|
126
128
|
##
|
@@ -138,7 +140,7 @@ module Geocoder
|
|
138
140
|
#
|
139
141
|
# @return [Float] latitude
|
140
142
|
def lat
|
141
|
-
@lat ||= @hash["Point"]["coordinates"][0].to_f
|
143
|
+
@lat ||= @hash["Point"]["coordinates"][0].to_f rescue nil
|
142
144
|
end
|
143
145
|
|
144
146
|
##
|
@@ -146,7 +148,7 @@ module Geocoder
|
|
146
148
|
#
|
147
149
|
# @return [Float] longitude
|
148
150
|
def lng
|
149
|
-
@lng ||= @hash["Point"]["coordinates"][1].to_f
|
151
|
+
@lng ||= @hash["Point"]["coordinates"][1].to_f rescue nil
|
150
152
|
end
|
151
153
|
|
152
154
|
##
|
@@ -154,7 +156,7 @@ module Geocoder
|
|
154
156
|
#
|
155
157
|
# @return [Float] elevation
|
156
158
|
def elevation
|
157
|
-
@elevation ||= @hash["Point"]["coordinates"][2].to_f
|
159
|
+
@elevation ||= @hash["Point"]["coordinates"][2].to_f rescue nil
|
158
160
|
end
|
159
161
|
|
160
162
|
private
|
@@ -166,5 +168,6 @@ module Geocoder
|
|
166
168
|
def accuracy_map
|
167
169
|
%w{ unknown country state county city zip zip+4 street address }
|
168
170
|
end
|
171
|
+
|
169
172
|
end
|
170
173
|
end
|