Skip to content
Snippets Groups Projects
Commit eafa579e authored by Alex Reisner's avatar Alex Reisner
Browse files

Deprecate old distance_to/from argument format.

parent 712d6cc0
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,9 @@ module Geocoder
# Also takes a symbol specifying the units (:mi or :km; default is :mi).
#
def distance_to(point, *args)
if point.is_a?(Numeric) and args[0].is_a?(Numeric)
warn "DEPRECATION WARNING: Instead of passing latitude/longitude as separate arguments to the distance_to/from method, please pass an array [#{point},#{args[0]}], a geocoded object, or a geocodable address (string). The old argument format will not be supported in Geocoder v.1.0."
end
return nil unless geocoded?
units = args.last.is_a?(Symbol) ? args.pop : :mi
them = args.size > 0 ? [point, args.first] :
......
......@@ -34,13 +34,13 @@ class GeocoderTest < Test::Unit::TestCase
def test_distance_to_returns_float
v = Venue.new(*venue_params(:msg))
v.latitude, v.longitude = [40.750354, -73.993371]
assert (d = v.distance_to(30, -94)).is_a?(Float)
assert (d = v.distance_to([30, -94])).is_a?(Float)
end
def test_distance_from_is_alias_for_distance_to
v = Venue.new(*venue_params(:msg))
v.latitude, v.longitude = [40.750354, -73.993371]
assert_equal v.distance_from(30, -94), v.distance_to(30, -94)
assert_equal v.distance_from([30, -94]), v.distance_to([30, -94])
end
def test_coordinates_method
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment