Class: Parse::GeoPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/datatypes.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ GeoPoint

Returns a new instance of GeoPoint.



244
245
246
247
# File 'lib/parse/datatypes.rb', line 244

def initialize(data)
  @longitude = data['longitude'] || data[:longitude]
  @latitude  = data['latitude'] || data[:latitude]
end

Instance Attribute Details

#latitudeObject

Returns the value of attribute latitude.



242
243
244
# File 'lib/parse/datatypes.rb', line 242

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



242
243
244
# File 'lib/parse/datatypes.rb', line 242

def longitude
  @longitude
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


249
250
251
252
253
# File 'lib/parse/datatypes.rb', line 249

def eql?(other)
  self.class.equal?(other.class) &&
    longitude == other.longitude &&
    latitude == other.latitude
end

#hashObject



256
257
258
# File 'lib/parse/datatypes.rb', line 256

def hash
  longitude.hash ^ latitude.hash
end

#to_h(*_a) ⇒ Object Also known as: as_json



260
261
262
263
264
265
266
# File 'lib/parse/datatypes.rb', line 260

def to_h(*_a)
  {
    Protocol::KEY_TYPE => Protocol::TYPE_GEOPOINT,
    'latitude' => @latitude,
    'longitude' => @longitude
  }
end

#to_json(*a) ⇒ Object



269
270
271
# File 'lib/parse/datatypes.rb', line 269

def to_json(*a)
  to_h.to_json(*a)
end

#to_sObject



273
274
275
# File 'lib/parse/datatypes.rb', line 273

def to_s
  "(#{latitude}, #{longitude})"
end