class Google::Maps::Route

Attributes

from[RW]
options[RW]
to[RW]

Public Class Methods

new(from, to, options = {}) click to toggle source
# File lib/google_maps/route.rb, line 10
def initialize(from, to, options = {})
  options = { language: options } unless options.is_a? Hash
  @from = from
  @to = to
  @options = { language: :en }.merge(options)
end

Public Instance Methods

destination_latlong() click to toggle source
# File lib/google_maps/route.rb, line 33
def destination_latlong
  "#{end_location.lat},#{end_location.lng}"
end
method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/google_maps/route.rb, line 17
def method_missing(method_name, *args, &block)
  if route.legs.first.key?(method_name)
    route.legs.first.send(method_name)
  else
    super
  end
end
origin_latlong() click to toggle source
# File lib/google_maps/route.rb, line 29
def origin_latlong
  "#{start_location.lat},#{start_location.lng}"
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/google_maps/route.rb, line 25
def respond_to_missing?(method_name, include_private = false)
  route.legs.first.key?(method_name) || super
end

Private Instance Methods

route() click to toggle source
# File lib/google_maps/route.rb, line 39
def route
  # default to the first returned route (the most efficient one)
  @route ||= API.query(:directions_service, @options.merge(origin: from, destination: to)).routes.first
end