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.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cta_redux/models/bus.rb', line 71 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.
65 66 67 |
# File 'lib/cta_redux/models/bus.rb', line 65 def delayed @delayed end |
#heading ⇒ Integer (readonly)
Returns The heading of the CTA::Bus.
57 58 59 |
# File 'lib/cta_redux/models/bus.rb', line 57 def heading @heading end |
#lat ⇒ Float (readonly)
Returns The latitude of the CTA::Bus.
51 52 53 |
# File 'lib/cta_redux/models/bus.rb', line 51 def lat @lat end |
#lon ⇒ Float (readonly)
Returns The longitude of the CTA::Bus.
53 54 55 |
# File 'lib/cta_redux/models/bus.rb', line 53 def lon @lon end |
#pattern_distance ⇒ Integer (readonly)
Returns The distance into the pattern the CTA::Bus is following.
61 62 63 |
# File 'lib/cta_redux/models/bus.rb', line 61 def pattern_distance @pattern_distance end |
#pattern_id ⇒ Integer (readonly)
Returns The pattern the CTA::Bus is following.
59 60 61 |
# File 'lib/cta_redux/models/bus.rb', line 59 def pattern_id @pattern_id end |
#predictions ⇒ Array<Prediction> (readonly)
Returns Predictions for this CTA::Bus.
69 70 71 |
# File 'lib/cta_redux/models/bus.rb', line 69 def predictions @predictions end |
#route ⇒ CTA::Route (readonly)
63 64 65 |
# File 'lib/cta_redux/models/bus.rb', line 63 def route @route end |
#speed ⇒ Integer (readonly)
Returns Last reported speed of the CTA::Bus, in mph.
67 68 69 |
# File 'lib/cta_redux/models/bus.rb', line 67 def speed @speed end |
#vehicle_id ⇒ Integer (readonly)
Returns The vehicle_id of the CTA::Bus.
55 56 57 |
# File 'lib/cta_redux/models/bus.rb', line 55 def vehicle_id @vehicle_id end |