Class: CTA::BusTracker::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/cta_redux/api/bus_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ Point

Returns a new instance of Point.



217
218
219
220
221
222
223
224
# File 'lib/cta_redux/api/bus_tracker.rb', line 217

def initialize(p)
  @sequence = p["seq"].to_i
  @lat = @latitude = p["lat"].to_f
  @lon = @longitude = p["lon"].to_f
  @type = (p["typ"] == "S" ? :stop : :waypoint)
  @stop = CTA::Stop.where(:stop_id => p["stpid"]).first || CTA::Stop.new_from_api_response(p)
  @distance = p["pdist"].to_f if p["pdist"]
end

Instance Attribute Details

#distanceFloat (readonly)

Returns The physical distance into a CTA::BusTracker::Pattern that corresponds to this CTA::BusTracker::Point.

Returns:



215
216
217
# File 'lib/cta_redux/api/bus_tracker.rb', line 215

def distance
  @distance
end

#latFloat (readonly)

Returns The latitude of this CTA::BusTracker::Point.

Returns:



203
204
205
# File 'lib/cta_redux/api/bus_tracker.rb', line 203

def lat
  @lat
end

#latitudeFloat (readonly)

Returns The latitude of this CTA::BusTracker::Point.

Returns:



207
208
209
# File 'lib/cta_redux/api/bus_tracker.rb', line 207

def latitude
  @latitude
end

#lonFloat (readonly)

Returns The longitude of this CTA::BusTracker::Point.

Returns:



205
206
207
# File 'lib/cta_redux/api/bus_tracker.rb', line 205

def lon
  @lon
end

#longitudeFloat (readonly)

Returns The longitude of this CTA::BusTracker::Point.

Returns:



209
210
211
# File 'lib/cta_redux/api/bus_tracker.rb', line 209

def longitude
  @longitude
end

#sequenceInteger (readonly)

Returns The order that this CTA::BusTracker::Point appears along a CTA::BusTracker::Pattern.

Returns:



201
202
203
# File 'lib/cta_redux/api/bus_tracker.rb', line 201

def sequence
  @sequence
end

#stopCTA::Stop (readonly)

Returns The Stop associated with this point.

Returns:



213
214
215
# File 'lib/cta_redux/api/bus_tracker.rb', line 213

def stop
  @stop
end

#typeSymbol (readonly)

Returns The type of this CTA::BusTracker::Point. One of [:stop, :waypoint].

Returns:



211
212
213
# File 'lib/cta_redux/api/bus_tracker.rb', line 211

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object



226
227
228
# File 'lib/cta_redux/api/bus_tracker.rb', line 226

def <=>(other)
  self.sequence <=> other.sequence
end