Class: MapQuest::Services::Directions

Inherits:
Core
  • Object
show all
Defined in:
lib/mapquest/services/directions.rb

Overview

The main class used for communicating with the MapQuest Directions API

Defined Under Namespace

Classes: Response

Constant Summary collapse

API_LOCATION =
:directions
VALID_OPTIONS =
[:to, :from]

Instance Attribute Summary

Attributes inherited from Core

#mapquest

Instance Method Summary collapse

Methods inherited from Core

#call_api, #initialize

Constructor Details

This class inherits a constructor from MapQuest::Services::Core

Instance Method Details

#route(from, to, options = {}) ⇒ Object

Allows you to search for direction to a location. It returns a response object of the route

Example: .route :to => "London, UK", "Manchester, UK"

Required parameters

  • from [String] The location where to end route

  • to [String] The location from which to start route



16
17
18
19
20
21
22
23
24
# File 'lib/mapquest/services/directions.rb', line 16

def route(from, to, options = {})
  if from && to
    options[:to] = to
    options[:from] = from
    call_api self, 1, 'route', options
  else
    raise ArgumentError, 'The method must receive the to, and from parameters'
  end
end