Class: Parse::GeoPoint

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

Overview

GeoPoint


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ GeoPoint

Returns a new instance of GeoPoint.



136
137
138
139
140
141
142
143
144
# File 'lib/parse/datatypes.rb', line 136

def initialize(data)
  @longitude = data["longitude"]
  @latitude  = data["latitude"]
  
  if !@longitude && !@latitude
    @longitude = data[:longitude]
    @latitude  = data[:latitude]
  end
end

Instance Attribute Details

#latitudeObject

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



134
135
136
# File 'lib/parse/datatypes.rb', line 134

def latitude
  @latitude
end

#longitudeObject

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



134
135
136
# File 'lib/parse/datatypes.rb', line 134

def longitude
  @longitude
end

Instance Method Details

#as_json(*a) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/parse/datatypes.rb', line 146

def as_json(*a)
  {
      Protocol::KEY_TYPE => Protocol::TYPE_GEOPOINT,
      "latitude" => @latitude,
      "longitude" => @longitude
  }
end

#to_json(*a) ⇒ Object



154
155
156
# File 'lib/parse/datatypes.rb', line 154

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