class Parse::GeoPoint

GeoPoint


Attributes

latitude[RW]

‘{“location”: {“__type”:“GeoPoint”, “latitude”:40.0, “longitude”:-30.0}}’

longitude[RW]

‘{“location”: {“__type”:“GeoPoint”, “latitude”:40.0, “longitude”:-30.0}}’

Public Class Methods

new(data) click to toggle source
# File lib/parse/datatypes.rb, line 255
def initialize(data)
  @longitude = data["longitude"]
  @latitude  = data["latitude"]

  if !@longitude && !@latitude
    @longitude = data[:longitude]
    @latitude  = data[:latitude]
  end
end

Public Instance Methods

==(other)
Alias for: eql?
as_json(*a)
Alias for: to_h
eql?(other) click to toggle source
# File lib/parse/datatypes.rb, line 265
def eql?(other)
  self.class.equal?(other.class) &&
    longitude == other.longitude &&
    latitude == other.latitude
end
Also aliased as: ==
hash() click to toggle source
# File lib/parse/datatypes.rb, line 273
def hash
  longitude.hash ^ latitude.hash
end
to_h(*a) click to toggle source
# File lib/parse/datatypes.rb, line 277
def to_h(*a)
  {
      Protocol::KEY_TYPE => Protocol::TYPE_GEOPOINT,
      "latitude" => @latitude,
      "longitude" => @longitude
  }
end
Also aliased as: as_json
to_json(*a) click to toggle source
# File lib/parse/datatypes.rb, line 286
def to_json(*a)
  to_h.to_json(*a)
end
to_s() click to toggle source
# File lib/parse/datatypes.rb, line 290
def to_s
  "(#{latitude}, #{longitude})"
end