Created
August 14, 2012 11:38
-
-
Save rymawby/3348536 to your computer and use it in GitHub Desktop.
Push TFL tube status updates to your iPhone using prowly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'prowly' | |
require 'rexml/document' | |
require 'net/http' | |
include REXML | |
@location = 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus' | |
@file = Net::HTTP.get_response(URI.parse(@location)) | |
@xml = REXML::Document.new(@file.body) | |
@output = "" | |
@xml.elements.each("ArrayOfLineStatus/LineStatus") do |element| | |
@output = @output + "#{element[3].attribute("Name")} - #{element[5].attribute("Description")}\n" | |
end | |
Prowly.notify do |n| | |
n.apikey = "???????????????????????????????" | |
n.priority = Prowly::Notification::Priority::MODERATE | |
n.application = "TFL Update" | |
n.event = "Alert" | |
n.description = @output | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment