lib/enrichment_db/geo/locator.rb in enrichment_db-0.1.1 vs lib/enrichment_db/geo/locator.rb in enrichment_db-0.1.2
- old
+ new
@@ -79,12 +79,13 @@
def self.format_geo(geo)
return geo if geo.is_a?(String)
fail EnrichmentDb::InvalidGeoPointFormat unless valid_geo_point?(geo)
- geo[:lat] ||= geo['lat']
- geo[:lon] ||= geo['lon']
- GeoHash.encode(geo[:lat], geo[:lon])
+ geo_format = geo.each_with_object({}) do |k, v, h|
+ h[k.to_sym] = v
+ end
+ GeoHash.encode(geo_format[:lat], geo_format[:lon])
end
def self.valid_geo_point?(geo_point)
geo_point.is_a?(Hash) && geo_point.keys.sort.collect(&:to_sym) == [:lat, :lon]
end