Between points integrated and estimated times
[bus.git] / maxious-canberra-transit-feed / 01-extracttimes.rb
blob:a/maxious-canberra-transit-feed/01-extracttimes.rb -> blob:b/maxious-canberra-transit-feed/01-extracttimes.rb
--- a/maxious-canberra-transit-feed/01-extracttimes.rb
+++ b/maxious-canberra-transit-feed/01-extracttimes.rb
@@ -14,7 +14,11 @@
 	timetable = {"between_stops" => [], "short_name" => short_name}
 	time_points = table.xpath('tr[1]//th').map do |tp|
 		if tp.content != "\302\240" && tp.content != "" && tp.content != "<br/>"
-			timing_point = tp.content.squeeze(" ").gsub("\r\n Platform"," - Platform").gsub("  - "," - ").gsub("\n","").gsub("\r","").gsub("\\"," / ").strip
+			timing_point = tp.content.squeeze(" ").gsub(" Platform"," (Platform").gsub("  - "," - ").gsub("\n","").gsub("\r","").gsub("\\"," / ").squeeze(" ").strip
+			if (tp.content.match('Platform'))
+			  timing_point.concat(")")
+			end;
+			timing_point
 		end
 	end
 	time_points.delete(nil)
@@ -42,7 +46,7 @@
 	timetable[period] = periodtimes.to_a
 	# pp timetable
 	filename = timetable["short_name"] + "-" + timetable["long_name"]+ "." + period + ".yml"
-	filename = filename.downcase.gsub(" ","-").gsub("/","-")
+	filename = filename.downcase.gsub(" ","-").gsub("/","-").gsub("(","").gsub(")","")
 	puts "Saving " + filename
 	File.open("#{File.dirname(__FILE__)}/output/"+filename, "w") do |f|
 		f.write timetable.to_yaml