pennride: A humble ruby gem hoping to make sense of Penn Transit

There are cool new Penn Transit buses, but not a single Penn student ever uses them. This must piss someone in the administration off, right?

Well, maybe more students would hop on a bus if they knew:

  • where the buses stopped (some routes go to Rittenhouse – this means free transport to Center City)
  • when the buses are expected to arrive at each stop

There is an obscure PennRide website that has live schedule and map data for buses, but I don’t think anybody knows it exists.

pennride provides you with an easy way to access arrival times by route and stop. Read on to learn how to use the gem.

Installation

pennride is hosted on rubygems, so run

gem install pennride

to install.

Alternatively, include gem 'pennride' in your gemfile and run bundle install.

How to use pennride

pennride emulates the PennRide bus system through a hierarchy consisting of Routes and Stops.

Routes

Routes are individual bus lines within the PennRide system. There are 5 routes:

  • East Shuttle Route
  • PennBUS East
  • PennBUS West
  • West Shuttle Route A
  • West Shuttle Route B

Each Route contains several Stops, and Routes may have any number of Stops.

List all Routes

“by require ‘pennride’ pennride = Pennride.new p pennride.routes

Get all Stops for a certain Route

“by require ‘pennride’ pennride = Pennride.new routes = pennride.routes route = routes.first # East Shuttle Route stops = route.stops

Stops

Note: Because PennRide is not in operation as of this gem’s writing, there is no way for me to test the arrival time function. The gem and docs will be updated when the schedule information becomes available.

Stops are, logically, individual bus stops on a given Route. A Stop’s arrival_time attribute is an array of Strings, each representing the expected arrival time of the next shuttle. For example, arrival_time[0] would give you the arrival time of the next bus, arrival_time[1] the next, and so on.

Get the arrival times of a Stop

“by require ‘pennride’ pennride = Pennride.new routes = pennride.routes route = routes.first # East Shuttle Route stops = route.stops stop = route.stops.first p stop.arrival_times

Web API

I plan to make the PennRide information available through a RESTful JSON web API. When the API is available, this section will be updated with the information needed to access the API.

Contributing

If you find any bugs or have feature ideas, feel free to fork and send me a pull request.

License

MIT License (see ./LICENSE), which means you can take this code and do whatever you’d like with it. If you do make use of the source code or the gem, I ask that you do two things:

  1. Give me/this project a hat tip
  2. Send me the link to your project, so I can feature it on this page