Class: CTA::BusTracker::Point
- Inherits:
-
Object
- Object
- CTA::BusTracker::Point
- Defined in:
- lib/cta_redux/api/bus_tracker.rb
Instance Attribute Summary collapse
- #distance ⇒ Float readonly
-
#lat ⇒ Float
readonly
The latitude of this Point.
-
#latitude ⇒ Float
readonly
The latitude of this Point.
-
#lon ⇒ Float
readonly
The longitude of this Point.
-
#longitude ⇒ Float
readonly
The longitude of this Point.
- #sequence ⇒ Integer readonly
-
#stop ⇒ CTA::Stop
readonly
The Stop associated with this point.
-
#type ⇒ Symbol
readonly
The type of this Point.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(p) ⇒ Point
constructor
A new instance of Point.
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
#distance ⇒ Float (readonly)
Returns The physical distance into a CTA::BusTracker::Pattern that corresponds to this CTA::BusTracker::Point.
215 216 217 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 215 def distance @distance end |
#lat ⇒ Float (readonly)
Returns The latitude of this CTA::BusTracker::Point.
203 204 205 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 203 def lat @lat end |
#latitude ⇒ Float (readonly)
Returns The latitude of this CTA::BusTracker::Point.
207 208 209 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 207 def latitude @latitude end |
#lon ⇒ Float (readonly)
Returns The longitude of this CTA::BusTracker::Point.
205 206 207 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 205 def lon @lon end |
#longitude ⇒ Float (readonly)
Returns The longitude of this CTA::BusTracker::Point.
209 210 211 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 209 def longitude @longitude end |
#sequence ⇒ Integer (readonly)
Returns The order that this CTA::BusTracker::Point appears along a CTA::BusTracker::Pattern.
201 202 203 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 201 def sequence @sequence end |
#stop ⇒ CTA::Stop (readonly)
Returns The Stop associated with this point.
213 214 215 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 213 def stop @stop end |
#type ⇒ Symbol (readonly)
Returns The type of this CTA::BusTracker::Point. One of [:stop, :waypoint].
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 |