Class: CTA::BusTracker::RoutesResponse

Inherits:
API::Response show all
Defined in:
lib/cta_redux/api/bus_tracker.rb

Instance Attribute Summary collapse

Attributes inherited from API::Response

#error, #parsed_body, #raw_body, #timestamp

Instance Method Summary collapse

Constructor Details

#initialize(parsed_body, raw_body, debug) ⇒ RoutesResponse

Returns a new instance of RoutesResponse.



39
40
41
42
43
44
45
46
47
# File 'lib/cta_redux/api/bus_tracker.rb', line 39

def initialize(parsed_body, raw_body, debug)
  super(parsed_body, raw_body, debug)
  @routes = Array.wrap(parsed_body["bustime_response"]["route"]).map do |r|
    rt = CTA::Route.where(:route_id => r["rt"]).first
    rt.route_color = r["rtclr"]

    rt
  end
end

Instance Attribute Details

#routesArray<CTA::Route> (readonly)

Returns An array with a full Route object for each route returned by the API, augmented with the color that the API thinks you should be using (which is not always found in the GTFS data).

Returns:

  • (Array<CTA::Route>)

    An array with a full Route object for each route returned by the API, augmented with the color that the API thinks you should be using (which is not always found in the GTFS data).



37
38
39
# File 'lib/cta_redux/api/bus_tracker.rb', line 37

def routes
  @routes
end