Class: Stretchy::Types::GeoPoint

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Validation

#errors, included, #require_one!, #require_only_one!, #valid?, #validate!, #validator

Constructor Details

#initialize(options = {}) ⇒ GeoPoint

Returns a new instance of GeoPoint.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/stretchy/types/geo_point.rb', line 17

def initialize(options = {})
  if options.is_a?(self.class)
    @lat = options.lat
    @lon = options.lon
  else
    @lat = options[:lat] || options[:latitude]
    @lon = options[:lng] || options[:lon] ||
           options[:longitude]
  end

  validate!
end

Instance Attribute Details

#latObject (readonly)

Returns the value of attribute lat.



15
16
17
# File 'lib/stretchy/types/geo_point.rb', line 15

def lat
  @lat
end

#lonObject (readonly)

Returns the value of attribute lon.



15
16
17
# File 'lib/stretchy/types/geo_point.rb', line 15

def lon
  @lon
end

Instance Method Details

#to_searchObject



30
31
32
33
34
35
# File 'lib/stretchy/types/geo_point.rb', line 30

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