From f93dc44949e54add9ea8f693967d1f15440e75a2 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Tue, 19 May 2015 14:39:27 +0100 Subject: [PATCH] Add mapping for weekend line names. --- tubestatus.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tubestatus.rb b/tubestatus.rb index a4957b1..74cc9ca 100644 --- a/tubestatus.rb +++ b/tubestatus.rb @@ -41,8 +41,10 @@ class Tubestatus < Sinatra::Base messages = [] end - { :id => line["Name"].first.downcase.gsub(/ (&)?/, ""), - :name => line["Name"].first, + name = weekend_line_mapping(line["Name"].first) + + { :id => name.downcase.gsub(/[^a-z]+/, "-"), + :name => name, :status => line["Status"].first["Text"].first.downcase, :messages => messages } end @@ -50,4 +52,10 @@ class Tubestatus < Sinatra::Base content_type :json JSON data end + + def weekend_line_mapping(name) + mapping = { 'H\'smith & City' => 'Hammersmith and City', + 'Waterloo & City' => 'Waterloo and City' } + mapping[name] || name + end end