Class: GoMaps::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/go_maps/address.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


7
8
9
# File 'lib/go_maps/address.rb', line 7

def exists?
  location['status'] == 'OK'
end

#latitudeObject



20
21
22
# File 'lib/go_maps/address.rb', line 20

def latitude
  geometry["lat"]
end

#longitudeObject



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, options = {})
  options[:language] ||= 'en'
  directions_to(address, "&language=#{options[:language]}")['routes'].first['legs'].first rescue raise AddressNotFoundException
end