Should I run for the train?
Whenver I need to catch the LIRR, I usually end up running. And If I’m dodging and weaving around the fine people of NYC, I hope there’s a train warmed up and ready to go when I get to the station. Given that I spend so much time in the terminal (…on my computer) these days, I decided to build a gem that makes sure everything is ok with my train before the race begins by pulling the latest train service status data off the MTA webiste.
The gem can be installed by typing the following into your terminal:
Type in the following command into your terminal and you will get the subway service status by default.
If you type lirr, metro-north, or a host of other related terms after the mta_status command you should get the service status for that particular branch of the MTA. For example, the following will get you the service status for the LIRR.
In addition to service status, the developer site also has links to schedules and route information all meant to follow the General Transit Feed Specification (GTFS) specs. In other words, if you build something for one transit system, it will likely be transferrable to one of these other transits systems in the US and through the rest of the world.
The MTA service status page is a text file with no css. In my previous (and limited) experence with Nokogiri I had searched for nodes using css, so with this page I had to search for nodes using xpath.
The page was layed out well so it didn’t take too long to figure out how to get xpath to find what I was looking for. Let me rephrase that, the page was pretty well laid out expcept for this:
This is the “text” that explains the service disruption. My next task is to make sense of this mess and then potentially work it into a new version of the gem. Only issue there is the more features I add, the less useful the gem could become, especially since the service change information is often confusing.
I get the following gem related error everytime the gem runs. It doesn’t seem to effect how the gem runs, but it is ugly.
Also, there’s a ton of information on the bus system that I didn’t incorporate and also some information on the bridges and tunnels operated by the MTA.
Make yourself useful.