cta_redux is a comprehensive gem for accessing CTA TrainTracker, BusTracker, customer alerts, and GTFS data
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
ext/inflate_database
lib
script
spec
.gitignore
.rspec
.travis.yml
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
cta_redux.gemspec

README.md

cta_redux

Build Status

The CTA (http://www.transitchicago.com) provides a wealth of information for developers, but it's hard to access, inconsistent, and there are no official clients. CTA Redux is an easy to use, comprehensive client for that data.

This gem combines GTFS data with live API responses to create a consistent view of CTA vehicles and status.

Examples:

require 'cta_redux'

CTA::TrainTracker.key = 'foo'
CTA::BusTracker.key   = 'bar'

# Pick a random stop on the brown line
stop = CTA::Route[:brown].stops.all.sample

routes = []
stop.predictions!.predictions.sort_by(&:seconds).each do |prd|
  routes << prd.route.route_id
  puts "A #{prd.direction} #{prd.route.route_long_name} " +
    "train will be arriving at #{stop.stop_name} in #{prd.minutes} minutes."
end

# Pick a random stop on the 8-Halsted route
stop = CTA::Route["8"].stops.all.sample
stop.predictions!.predictions.sort_by(&:seconds).each do |prd|
  routes << prd.route.route_id
  puts "A(n) #{prd.route.route_id}-#{prd.route.route_long_name} will be " +
    "arriving at #{stop.stop_name} in #{prd.minutes} minutes."
end

CTA::CustomerAlerts.alerts!(:routes => routes.uniq).alerts.each do |alert|
  puts "Alert: #{alert.short_description}"
end

More information is available at (http://www.rubydoc.info/github/ahayworth/cta_redux)