diff --git a/lib/geocoder/calculations.rb b/lib/geocoder/calculations.rb index c1eb9525c9199907239e2f8cb882e44c935b6189..ed9f89c2d9bc02ea18a67cb427a56cb545ed7312 100644 --- a/lib/geocoder/calculations.rb +++ b/lib/geocoder/calculations.rb @@ -38,12 +38,7 @@ module Geocoder # Returns true if all given arguments are valid latitude/longitude values. # def coordinates_present?(*args) - args.each do |a| - # note that Float::NAN != Float::NAN - # still, this could probably be improved: - return false if (!a.is_a?(Numeric) or a.to_s == "NaN") - end - true + args.all? { |a| a.is_a? Numeric and !a.to_f.nan? } end ## @@ -407,13 +402,8 @@ module Geocoder def extract_coordinates(point) case point when Array - if point.size == 2 - lat, lon = point - if !lat.nil? && lat.respond_to?(:to_f) and - !lon.nil? && lon.respond_to?(:to_f) - then - return [ lat.to_f, lon.to_f ] - end + if point.size == 2 and coordinates_present?(*point) + return point.map {|coords| coords.to_f} end when String point = Geocoder.coordinates(point) and return point