diff --git a/lib/geocoder.rb b/lib/geocoder.rb index 03a9c0897b0a8063c977c733dcf40a2af159e21f..ddca673d0165edb14444c5e60c36f0b99386f7f3 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 99f6d622306becffd409c0863d2be5d62275d469..d705810acd1dd72932a0bd82d2eecc8c342595dc 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