Class: CTA::BusTracker::Service
- Inherits:
-
Object
- Object
- CTA::BusTracker::Service
- Defined in:
- lib/cta_redux/api/bus_tracker.rb
Instance Attribute Summary collapse
-
#direction ⇒ Direction
readonly
A Direction object for the direction, if any, affected by a ServiceBulletin.
-
#route ⇒ CTA::Route
readonly
A Route, if any, affected by a ServiceBulletin.
-
#stop ⇒ CTA::Stop
readonly
A specific Stop object for the stop affected by a ServiceBulletin.
-
#stop_name ⇒ String
readonly
The name of the Stop affected.
Instance Method Summary collapse
-
#initialize(s) ⇒ Service
constructor
A new instance of Service.
- #predictions! ⇒ Object
Constructor Details
#initialize(s) ⇒ Service
Returns a new instance of Service.
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 154 def initialize(s) @route = CTA::Route.where(:route_id => s["rt"]).first @direction = Direction.new(s["rtdir"]) if s["rtdir"] if s["stpid"] @stop = CTA::Stop.where(:stop_id => s["stpid"]).first || CTA::Stop.new_from_api_response(s) @stop_name = @stop.name else @stop_name = s["stpnm"] # ugh end end |
Instance Attribute Details
#direction ⇒ Direction (readonly)
Returns A Direction object for the direction, if any, affected by a CTA::BusTracker::ServiceBulletin.
145 146 147 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 145 def direction @direction end |
#route ⇒ CTA::Route (readonly)
Returns A Route, if any, affected by a CTA::BusTracker::ServiceBulletin.
143 144 145 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 143 def route @route end |
#stop ⇒ CTA::Stop (readonly)
Returns A specific Stop object for the stop affected by a CTA::BusTracker::ServiceBulletin.
147 148 149 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 147 def stop @stop end |
#stop_name ⇒ String (readonly)
Usually this is equivalent to calling stop.name
, but sometimes the CTA returns a CTA::BusTracker::ServiceBulletin with a stop name, but no stop id set - and the stop name may not exactly correspond to a Stop object in the GTFS feed.
Returns The name of the Stop affected.
152 153 154 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 152 def stop_name @stop_name end |
Instance Method Details
#predictions! ⇒ Object
165 166 167 168 169 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 165 def predictions! = { :route => self.route } .merge!({ :stop => self.stop_id }) if self.stop_id CTA::BusTracker.predictions!() end |