From d6de30a4ddcd68b349f050cf361e99032cc60439 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Tue, 5 Apr 2011 13:17:45 -0400 Subject: [PATCH] Change Geocoder.address argument format. --- lib/geocoder.rb | 11 ++++++++--- test/geocoder_test.rb | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/geocoder.rb b/lib/geocoder.rb index 03a9c089..ddca673d 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -49,10 +49,15 @@ module Geocoder end ## - # Look up the address of the given coordinates. + # Look up the address of the given coordinates ([lat,lon]) + # or IP address (string). # - def address(latitude, longitude) - if (results = search([latitude, longitude])).size > 0 + def address(query, *args) + if lon = args.first + warn "DEPRECATION WARNING: Instead of passing latitude/longitude as separate arguments to the address method, please pass an array: [#{query},#{args.first}]. The old argument format will not be supported in Geocoder v.1.0." + query = [query, lon] + end + if (results = search(query)).size > 0 results.first.address end end diff --git a/test/geocoder_test.rb b/test/geocoder_test.rb index 99f6d622..d705810a 100644 --- a/test/geocoder_test.rb +++ b/test/geocoder_test.rb @@ -48,7 +48,7 @@ class GeocoderTest < Test::Unit::TestCase end def test_address_method - assert Geocoder.address(40.750354, -73.993371).is_a?(String) + assert Geocoder.address([40.750354, -73.993371]).is_a?(String) end def test_geographic_center_doesnt_overwrite_argument_value -- GitLab