Module: Gdirections
- Includes:
- HTTParty
- Defined in:
- lib/gdirections.rb
Defined Under Namespace
Classes: Route
Class Method Summary collapse
Class Method Details
.get_directions(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gdirections.rb', line 10 def self.get_directions( = {}) = { :origin => nil, :destination => nil, :mode => :driving, :sensor => :false, :waypoints => nil, :optimize => true }.merge() raise ArgumentError, "Origin required" if [:origin].nil? raise ArgumentError, "Destination required" if [:destination].nil? if [:waypoints] && [:waypoints].is_a?(Array) [:waypoints] = "optimize:#{(.delete(:optimize) == true).to_s}|" + [:waypoints].join('|') end result = get("/maps/api/directions/json", :query => ) if result Route.new(result.parsed_response) end end |