Class: GeoPoint
Instance Attribute Summary collapse
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ GeoPoint
constructor
A new instance of GeoPoint.
- #to_geo_point ⇒ Object
- #to_parse ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ GeoPoint
Returns a new instance of GeoPoint.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/opium/extensions/geo_point.rb', line 2 def initialize( value ) self.latitude, self.longitude = * case value when Hash [value[:latitude] || value['latitude'], value[:longitude] || value['longitude']] when Array [value.first, value.last] else raise ArgumentError.new( "invalid value for GeoPoint: \"#{value}\"" ) end end |
Instance Attribute Details
#latitude ⇒ Object
Returns the value of attribute latitude.
14 15 16 |
# File 'lib/opium/extensions/geo_point.rb', line 14 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
14 15 16 |
# File 'lib/opium/extensions/geo_point.rb', line 14 def longitude @longitude end |
Class Method Details
.to_parse(object) ⇒ Object
33 34 35 |
# File 'lib/opium/extensions/geo_point.rb', line 33 def to_parse(object) object.to_geo_point.to_parse end |
.to_ruby(object) ⇒ Object
29 30 31 |
# File 'lib/opium/extensions/geo_point.rb', line 29 def to_ruby(object) object.to_geo_point unless object.nil? end |
Instance Method Details
#to_geo_point ⇒ Object
16 17 18 |
# File 'lib/opium/extensions/geo_point.rb', line 16 def to_geo_point self end |
#to_parse ⇒ Object
20 21 22 |
# File 'lib/opium/extensions/geo_point.rb', line 20 def to_parse { "__type" => "GeoPoint", "latitude" => self.latitude, "longitude" => self.longitude } end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/opium/extensions/geo_point.rb', line 24 def to_s "#{self.latitude},#{self.longitude}" end |