-
-
Notifications
You must be signed in to change notification settings - Fork 8
Implementation
Roderick Monje edited this page Nov 14, 2021
·
3 revisions
GoogleMapsGeocoder
is a simple plain-old Ruby object initialized with an address:
chez_barack = GoogleMapsGeocoder.new '1600 Pennsylvania DC'
Upon initialization, GoogleMapsGeocoder
:
- requests the Google Maps API to geocode the given address
- parses the results
- makes the results available via standard getters
For example, to get the complete, formatted address:
chez_barack.formatted_address
=> "1600 Pennsylvania Avenue Northwest, President's Park, Washington, DC 20500, USA"
...standardized name of the city:
chez_barack.city
=> "Washington"
...full name of the state or region:
chez_barack.state_long_name
=> "District of Columbia"
...standard abbreviation for the state/region:
chez_barack.state_short_name
=> "DC"
For more information, review the gem's unit test, which can also be run via:
bundle ex rspec -f d