Class: Geocoder::Address
- Inherits:
-
Object
- Object
- Geocoder::Address
- Defined in:
- lib/geocoder/response.rb
Instance Method Summary collapse
-
#accuracy ⇒ String
Accuracy.
-
#address ⇒ String
Address.
-
#city ⇒ String
City.
-
#coordinates ⇒ <Array>
Coordinates.
-
#country ⇒ String
Country.
-
#elevation ⇒ Float
Elevation.
-
#initialize(hash) ⇒ Address
constructor
Initialize class.
-
#lat ⇒ Float
Lat.
-
#lng ⇒ Float
Lng.
-
#state ⇒ String
State.
-
#street ⇒ String
Street.
-
#zipcode ⇒ String
Zipcode.
Constructor Details
#initialize(hash) ⇒ Address
Initialize class
set @hash to the json parsed hash
58 59 60 |
# File 'lib/geocoder/response.rb', line 58 def initialize(hash) @hash = hash end |
Instance Method Details
#accuracy ⇒ String
Accuracy
Convert Googles Accuracy integer into a word describing how accurate the match is
122 123 124 |
# File 'lib/geocoder/response.rb', line 122 def accuracy @accuracy ||= accuracy_map[@hash["AddressDetails"]["Accuracy"].to_i] end |
#address ⇒ String
Address
66 67 68 |
# File 'lib/geocoder/response.rb', line 66 def address @address ||= @hash["address"] end |
#city ⇒ String
City
83 84 85 86 |
# File 'lib/geocoder/response.rb', line 83 def city @city ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\ ["Locality"]["LocalityName"] end |
#coordinates ⇒ <Array>
Coordinates
An array of coordinates in the form of [lat, lng, elevation]
132 133 134 |
# File 'lib/geocoder/response.rb', line 132 def coordinates @coordinates ||= [lat, lng, elevation] end |
#country ⇒ String
Country
110 111 112 |
# File 'lib/geocoder/response.rb', line 110 def country @country ||= @hash["AddressDetails"]["Country"]["CountryNameCode"] end |
#elevation ⇒ Float
Elevation
156 157 158 |
# File 'lib/geocoder/response.rb', line 156 def elevation @elevation ||= @hash["Point"]["coordinates"][2].to_f end |
#lat ⇒ Float
Lat
140 141 142 |
# File 'lib/geocoder/response.rb', line 140 def lat @lat ||= @hash["Point"]["coordinates"][0].to_f end |
#lng ⇒ Float
Lng
148 149 150 |
# File 'lib/geocoder/response.rb', line 148 def lng @lng ||= @hash["Point"]["coordinates"][1].to_f end |
#state ⇒ String
State
92 93 94 95 |
# File 'lib/geocoder/response.rb', line 92 def state @state ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\ ["AdministrativeAreaName"] end |
#street ⇒ String
Street
74 75 76 77 |
# File 'lib/geocoder/response.rb', line 74 def street @street ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\ ["Locality"]["Thoroughfare"]["ThoroughfareName"] end |
#zipcode ⇒ String
Zipcode
101 102 103 104 |
# File 'lib/geocoder/response.rb', line 101 def zipcode @zipcode ||= @hash["AddressDetails"]["Country"]["AdministrativeArea"]\ ["Locality"]["PostalCode"]["PostalCodeNumber"] end |