Module: Mongoid::Geo::Point
- Defined in:
- lib/mongoid/geo/point.rb
Instance Method Summary collapse
- #to_point ⇒ Object
-
#to_points ⇒ Object
convert hash or object to [x, y] of floats.
Instance Method Details
#to_point ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mongoid/geo/point.rb', line 9 def to_point case self when Hash return [self[:lat], self[:lng]] if self[:lat] return [self[:latitude], self[:longitude]] if self[:latitude] return [self['0'].to_f, self['1'].to_f] if self['0'] raise "Hash must contain either :lat, :lng or :latitude, :longitude keys to be converted to a geo point" when nil nil when Array self.map(&:to_f) else obj = self.send(:location) if respond_to? :location obj ||= self.send(:position) if self.respond_to? :position obj ||= self get_the_location obj end end |