Class: GoMaps::Address
- Inherits:
-
Object
- Object
- GoMaps::Address
- Defined in:
- lib/go_maps/address.rb
Instance Method Summary collapse
- #distance_to(address) ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(address) ⇒ Address
constructor
A new instance of Address.
- #latitude ⇒ Object
- #longitude ⇒ Object
- #route_to(address, options = {}) ⇒ Object
Constructor Details
#initialize(address) ⇒ Address
Returns a new instance of Address.
3 4 5 |
# File 'lib/go_maps/address.rb', line 3 def initialize(address) @address = address end |
Instance Method Details
#distance_to(address) ⇒ Object
11 12 13 |
# File 'lib/go_maps/address.rb', line 11 def distance_to(address) route_to(address)['distance']['text'].to_f end |
#exists? ⇒ Boolean
7 8 9 |
# File 'lib/go_maps/address.rb', line 7 def exists? location['status'] == 'OK' end |
#latitude ⇒ Object
20 21 22 |
# File 'lib/go_maps/address.rb', line 20 def latitude geometry["lat"] end |
#longitude ⇒ Object
24 25 26 |
# File 'lib/go_maps/address.rb', line 24 def longitude geometry["lng"] end |
#route_to(address, options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/go_maps/address.rb', line 15 def route_to(address, = {}) [:language] ||= 'en' directions_to(address, "&language=#{[:language]}")['routes'].first['legs'].first rescue raise AddressNotFoundException end |