diff --git a/lib/geocoder.rb b/lib/geocoder.rb index f8a5091ef59ad7684fafeb27833584921928ed4b..df03e5a59f1458b294b1c0c879de2b8e2e515720 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -23,6 +23,14 @@ module Geocoder coords.split(',')[0...2].reverse.map{ |i| i.to_f } end + ## + # Calculate the distance from the object to a point (lat,lon). Valid units + # are defined in <tt>distance_between</tt> class method. + # + def distance_to(lat, lon, units = :mi) + Geocoder.distance_between(latitude, longitude, lat, lon, :units => units) + end + ## # Search Google based on the object's +location+ attribute. #