From 502c1861e51dbf028dad64b06df774f40d825411 Mon Sep 17 00:00:00 2001 From: James Darling Date: Fri, 2 Sep 2011 17:59:04 +0100 Subject: [PATCH] init --- bus.rb | 11 +++++++++++ templates/stop.erb | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 bus.rb create mode 100644 templates/stop.erb diff --git a/bus.rb b/bus.rb new file mode 100644 index 0000000..f3a4863 --- /dev/null +++ b/bus.rb @@ -0,0 +1,11 @@ +require 'sinatra' +require 'net/http' +require 'json' +require 'erb' +set :views, File.dirname(__FILE__) + '/templates' + +get '/stop/:stop_id' do |stop_id| + response = Net::HTTP.get(URI.parse("http://countdown.tfl.gov.uk/stopBoard/#{stop_id}/")) + @json = JSON.parse(response) + erb :stop +end diff --git a/templates/stop.erb b/templates/stop.erb new file mode 100644 index 0000000..ee0927e --- /dev/null +++ b/templates/stop.erb @@ -0,0 +1,40 @@ + + + + + + Bus stop + + + + + + <% @json["arrivals"].each do |arrival| %> + + + + + <% end %> +
<%= arrival["routeId"] %><%= arrival["estimatedWait"] %>
+ +