Class: CTA::Bus::Live
- Inherits:
-
Object
- Object
- CTA::Bus::Live
- Defined in:
- lib/cta_redux/models/bus.rb
Instance Attribute Summary collapse
-
#delayed ⇒ true, false
readonly
True if the CTA::Bus is considered to be delayed.
-
#heading ⇒ Integer
readonly
The heading of the CTA::Bus.
-
#lat ⇒ Float
readonly
The latitude of the CTA::Bus.
-
#lon ⇒ Float
readonly
The longitude of the CTA::Bus.
-
#pattern_distance ⇒ Integer
readonly
The distance into the pattern the CTA::Bus is following.
-
#pattern_id ⇒ Integer
readonly
The pattern the CTA::Bus is following.
-
#predictions ⇒ Array<Prediction>
readonly
Predictions for this CTA::Bus.
- #route ⇒ CTA::Route readonly
-
#speed ⇒ Integer
readonly
Last reported speed of the CTA::Bus, in mph.
-
#vehicle_id ⇒ Integer
readonly
The vehicle_id of the CTA::Bus.
Instance Method Summary collapse
-
#initialize(position, predictions = []) ⇒ Live
constructor
A new instance of Live.
Constructor Details
#initialize(position, predictions = []) ⇒ Live
Returns a new instance of Live.
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/cta_redux/models/bus.rb', line 108 def initialize(position, predictions = []) @lat = position["lat"].to_f @lon = position["lon"].to_f @heading = position["hdg"].to_i @vehicle_id = position["vid"].to_i @pattern_id = position["pid"].to_i @pattern_distance = position["pdist"].to_i @route = CTA::Route.where(:route_id => position["rt"]).first @delayed = (position["dly"] == "true") @speed = position["spd"].to_i @predictions = Array.wrap(predictions).map { |p| Prediction.new(p) } end |
Instance Attribute Details
#delayed ⇒ true, false (readonly)
Returns True if the CTA::Bus is considered to be delayed.
102 103 104 |
# File 'lib/cta_redux/models/bus.rb', line 102 def delayed @delayed end |
#heading ⇒ Integer (readonly)
Returns The heading of the CTA::Bus.
94 95 96 |
# File 'lib/cta_redux/models/bus.rb', line 94 def heading @heading end |
#lat ⇒ Float (readonly)
Returns The latitude of the CTA::Bus.
88 89 90 |
# File 'lib/cta_redux/models/bus.rb', line 88 def lat @lat end |
#lon ⇒ Float (readonly)
Returns The longitude of the CTA::Bus.
90 91 92 |
# File 'lib/cta_redux/models/bus.rb', line 90 def lon @lon end |
#pattern_distance ⇒ Integer (readonly)
Returns The distance into the pattern the CTA::Bus is following.
98 99 100 |
# File 'lib/cta_redux/models/bus.rb', line 98 def pattern_distance @pattern_distance end |
#pattern_id ⇒ Integer (readonly)
Returns The pattern the CTA::Bus is following.
96 97 98 |
# File 'lib/cta_redux/models/bus.rb', line 96 def pattern_id @pattern_id end |
#predictions ⇒ Array<Prediction> (readonly)
Returns Predictions for this CTA::Bus.
106 107 108 |
# File 'lib/cta_redux/models/bus.rb', line 106 def predictions @predictions end |
#route ⇒ CTA::Route (readonly)
100 101 102 |
# File 'lib/cta_redux/models/bus.rb', line 100 def route @route end |
#speed ⇒ Integer (readonly)
Returns Last reported speed of the CTA::Bus, in mph.
104 105 106 |
# File 'lib/cta_redux/models/bus.rb', line 104 def speed @speed end |
#vehicle_id ⇒ Integer (readonly)
Returns The vehicle_id of the CTA::Bus.
92 93 94 |
# File 'lib/cta_redux/models/bus.rb', line 92 def vehicle_id @vehicle_id end |