Class: Stretchy::Types::GeoPoint

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/types/geo_point.rb

Constant Summary

Constants included from Utils::Contract

Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Contract

included, #require_one, #validate!

Constructor Details

#initialize(options = {}) ⇒ GeoPoint

Returns a new instance of GeoPoint.



13
14
15
16
17
18
19
# File 'lib/stretchy/types/geo_point.rb', line 13

def initialize(options = {})
  @lat = options[:lat] || options[:latitude]
  @lon = options[:lng] || options[:lon] ||
         options[:longitude]

  validate!
end

Instance Attribute Details

#latObject (readonly)

Returns the value of attribute lat.



7
8
9
# File 'lib/stretchy/types/geo_point.rb', line 7

def lat
  @lat
end

#lonObject (readonly)

Returns the value of attribute lon.



7
8
9
# File 'lib/stretchy/types/geo_point.rb', line 7

def lon
  @lon
end

Instance Method Details

#to_searchObject



21
22
23
24
25
26
# File 'lib/stretchy/types/geo_point.rb', line 21

def to_search
  {
    lat: @lat,
    lon: @lon
  }
end