Method: Misc::GeoPoint#initialize
- Defined in:
- lib/misc/geo_point.rb
#initialize(lat: nil, lng: nil, latlng: nil, geo_hash: nil) ⇒ GeoPoint
Returns a new instance of GeoPoint.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/misc/geo_point.rb', line 15 def initialize(lat: nil, lng: nil, latlng: nil, geo_hash: nil) if lat.present? && lng.present? @lat = lat.to_f @lng = lng.to_f @type = :float elsif latlng.present? @latlng = latlng @type = latlng.class.name.downcase.intern elsif geo_hash.present? @geo_hash = geo_hash @type = :geohash else raise 'Provide Point as floating values latitude and longitude or a string or an array or a geohash' end end |