From e9b682867a255a0513832d743312e866757f8517 Mon Sep 17 00:00:00 2001 From: Sameer Deshmukh Date: Sat, 23 Feb 2013 16:47:16 +0530 Subject: [PATCH] Works with co-ordinates --- lib/google_directions.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/google_directions.rb b/lib/google_directions.rb index 12fa114..bc2c57c 100644 --- a/lib/google_directions.rb +++ b/lib/google_directions.rb @@ -17,12 +17,19 @@ class GoogleDirections :sensor => :false, :mode => :driving, } - + def initialize(origin, destination, opts=@@default_options) @origin = origin @destination = destination - @options = opts.merge({:origin => transcribe(@origin), :destination => transcribe(@destination)}) - + @options = begin + opts = @@default_options.merge opts + if opts[:coordinates] + opts.merge({:origin => @origin, :destination => @destination}) + else + opts.merge({:origin => transcribe(@origin), :destination => transcribe(@destination)}) + end + end + @url = @@base_url + '?' + @options.to_params @xml = open(@url).read @doc = Nokogiri::XML(@xml)