Class: Parse::GeoPoint
- Inherits:
-
Object
- Object
- Parse::GeoPoint
- Defined in:
- lib/parse/datatypes.rb
Overview
GeoPoint
Instance Attribute Summary collapse
-
#latitude ⇒ Object
‘{“__type”:“GeoPoint”, “latitude”:40.0, “longitude”:-30.0}’.
-
#longitude ⇒ Object
‘{“__type”:“GeoPoint”, “latitude”:40.0, “longitude”:-30.0}’.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(data) ⇒ GeoPoint
constructor
A new instance of GeoPoint.
- #to_h(*a) ⇒ Object (also: #as_json)
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ GeoPoint
Returns a new instance of GeoPoint.
251 252 253 254 255 256 257 258 259 |
# File 'lib/parse/datatypes.rb', line 251 def initialize(data) @longitude = data["longitude"] @latitude = data["latitude"] if !@longitude && !@latitude @longitude = data[:longitude] @latitude = data[:latitude] end end |
Instance Attribute Details
#latitude ⇒ Object
‘{“__type”:“GeoPoint”, “latitude”:40.0, “longitude”:-30.0}’
249 250 251 |
# File 'lib/parse/datatypes.rb', line 249 def latitude @latitude end |
#longitude ⇒ Object
‘{“__type”:“GeoPoint”, “latitude”:40.0, “longitude”:-30.0}’
249 250 251 |
# File 'lib/parse/datatypes.rb', line 249 def longitude @longitude end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
261 262 263 264 265 |
# File 'lib/parse/datatypes.rb', line 261 def eql?(other) self.class.equal?(other.class) && longitude == other.longitude && latitude == other.latitude end |
#hash ⇒ Object
269 270 271 |
# File 'lib/parse/datatypes.rb', line 269 def hash longitude.hash ^ latitude.hash end |
#to_h(*a) ⇒ Object Also known as: as_json
273 274 275 276 277 278 279 |
# File 'lib/parse/datatypes.rb', line 273 def to_h(*a) { Protocol::KEY_TYPE => Protocol::TYPE_GEOPOINT, "latitude" => @latitude, "longitude" => @longitude } end |
#to_json(*a) ⇒ Object
282 283 284 |
# File 'lib/parse/datatypes.rb', line 282 def to_json(*a) to_h.to_json(*a) end |
#to_s ⇒ Object
286 287 288 |
# File 'lib/parse/datatypes.rb', line 286 def to_s "(#{latitude}, #{longitude})" end |