Class: CTA::Train

Inherits:
Trip
  • Object
show all
Defined in:
lib/cta_redux/models/train.rb

Overview

Note:

Current columns: [:route_id, :service_id, :trip_id, :direction_id, :block_id, :shape_id, :direction, :wheelchair_accessible, :schd_trip_id]

A Sequel::Model, inherited from Trip This corresponds to trips.txt in the GTFS feed, though the CTA does not fully implement the standard.

Defined Under Namespace

Classes: Live, Prediction

Constant Summary collapse

L_ROUTES =
{
  "red"   => { :name => "Red",
               :directions => { "1" => "Howard-bound", "5" => "95th/Dan Ryan-bound" }
  },
  "blue"  => { :name => "Blue",
               :directions => { "1" => "O'Hare-bound", "5" => "Forest Park-bound" }
  },
  "brn"   => { :name => "Brown",
               :directions => { "1" => "Kimball-bound", "5" => "Loop-bound" }
  },
  "g"     => { :name => "Green",
               :directions => { "1" => "Harlem/Lake-bound", "5" => "Ashland/63rd- or Cottage Grove-bound (toward 63rd St destinations)" }
  },
  "org"   => { :name => "Orange",
               :directions => { "1" => "Loop-bound", "5" => "Midway-bound" }
  },
  "p"     => { :name => "Purple",
               :directions => { "1" => "Linden-bound", "5" => "Howard- or Loop-bound" }
  },
  "pink"  => { :name => "Pink",
               :directions => { "1" => "Loop-bound", "5" => "54th/Cermak-bound" }
  },
  "y"     => { :name => "Yellow",
               :directions => { "1" => "Skokie-bound", "5" => "Howard-bound" }
  },
}
FRIENDLY_L_ROUTES =
Hash[L_ROUTES.values.map { |r| r[:name].downcase.to_sym }.zip(L_ROUTES.keys)]

Constants inherited from Trip

CTA::Trip::BUS_ROUTES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Trip

#calendar, find_active_run, #route, #stop_times, #stops

Instance Attribute Details

#liveLive

Note:

a CTA::Train will only contain live data when augmented with an API::Response

Returns the Live data associated with this CTA::Train object, if available.

Returns:



9
10
11
# File 'lib/cta_redux/models/train.rb', line 9

def live
  @live
end

Instance Method Details

#block_idInteger

Returns:

  • (Integer)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#directionString

Returns:

  • (String)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#direction_idInteger

Returns:

  • (Integer)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#follow!CTA::TrainTracker::FollowResponse

Follows a train, using the TrainTracker follow API

Returns:



63
64
65
# File 'lib/cta_redux/models/train.rb', line 63

def follow!
  CTA::TrainTracker.follow!(:run => self.schd_trip_id.gsub("R", ""))
end

#route_idString Also known as: id

Returns:

  • (String)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#schd_trip_idString Also known as: scheduled_trip_id, run

Returns:

  • (String)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#service_idInteger

Returns:

  • (Integer)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#shape_idInteger

Returns:

  • (Integer)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#trip_idInteger

Returns:

  • (Integer)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id

#wheelchair_accessibletrue, false

Returns:

  • (true, false)


57
# File 'lib/cta_redux/models/train.rb', line 57

alias_method :id, :route_id