Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First working spec for steps

  • Loading branch information...
commit 4e6bc35047c13e8b5d2deae37e4c6241e1b7e1d8 1 parent 451d449
@chendo authored
View
27 lib/metlinkr/step.rb
@@ -0,0 +1,27 @@
+class Metlinkr
+ class Step
+ attr_reader :method, :origin, :destination, :departure_time, :arrival_time, :duration
+
+ def self.parse(row_set)
+ step = new
+ step.parse(row_set)
+ end
+
+ def parse(row_set)
+ @row_set = row_set
+
+ parse_method
+
+ self
+ end
+
+ protected
+
+ def parse_method
+ @method = case @row_set[0].xpath("//td[1]/img").first.attributes['alt'].value
+ when /tram/i
+ :tram
+ end
+ end
+ end
+end
View
321 spec/fixtures/multiple_journey.html
@@ -0,0 +1,321 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="EN" xmlns="http://www.w3.org/1999/xhtml"><!--WEB, v1.23.2.11-->
+<head xmlns="">
+<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>Viclink Journey Planner - Your guide to public transport in Victoria</title><meta name="DC.Keywords" content="Metlink, melbourne public transport system, met link, train, trains, tram, trams, bus, buses, The Met, the met, metcard, public transport, transport, australia, Melbourne, Victoria, rail, Revitalising Victorian Rail, guide, route, reservation, vacation, holiday, time tables, timetables, timetable, travel, passenger, V-Line, V-Line Passenger, nightrider, Nightrider, Night Rider, night rider, City Circle, city circle"><meta name="Keywords" content="Metlink, melbourne public transport system, met link, train, trains, tram, trams, bus, buses, The Met, the met, metcard, public transport, transport, australia, Melbourne, Victoria, rail, guide, route,reservation, vacation, holiday, time tables, timetables, timetable, travel, passenger, V-Line, V-Line Passenger, nightrider, Nightrider, Night Rider, night rider, City Circle, city circle"><meta name="DC.Description" content="Welcome to Metlink - Your guide to public transport in metropolitan Melbourne. Find out about public train, tram and bus services throughout Melbourne and Victoria, Australia."><meta name="Description" content="Welcome to Metlink - Your guide to public transport in metropolitan Melbourne. Find out about public train, tram and bus services throughout Melbourne and Victoria, Australia."><meta name="DC.Publisher" content="Metlink Victoria Pty Ltd"><meta name="DC.Creator" content="Metlink Victoria Pty Ltd"><meta name="DC.Identifier" content="http://www.metlinkmelbourne.com.au"><meta http-equiv="Content-Language" content="en-au"><meta http-equiv="expires" content="0"><meta http-equiv="Pragma" content="no-cache"><!--
+ Copyright © 2007 Metlink Victoria Pty Ltd. All rights reserved
+ For more information or to report a bug, please contact Metlink at feedback@metlinkmelbourne.com.au or call 131 638.
+ --><!-- - links to stylesheet --><link rel="stylesheet" href="css/common.css" type="text/css"><link rel="stylesheet" href="css/style.css" type="text/css"><link rel="stylesheet" href="css/efa9_trips_jp.css"><link rel="stylesheet" href="css/phase2_jp.css" type="text/css"><link rel="stylesheet" href="css/efa9_print_jp.css" type="text/css" media="print"><link rel="stylesheet" href="css/efa9_metlink_jp_legtt.css" type="text/css"><!-- break frames --><script language="JavaScript" type="text/javascript"><!--
+ if (window != window.top)
+ top.location.href = location.href;
+ // --></script><!-- - links to all the JavaScript code for nav and popup windows --><script language="JavaScript" src="script/js_code.js" type="text/javascript"></script><script language="JavaScript" src="script/efa9_metlink_web.js" type="text/javascript"></script><script language="JavaScript" src="script/efa9_metlink_web_legtt.js" type="text/javascript"></script><script language="JavaScript" type="text/javascript">var mapDisplayCentre = false;</script><script language="JavaScript" type="text/javascript"><!--
+
+ function addToFavourites()
+ {
+ if(document.all)
+ {
+ window.external.AddFavorite("http://www.metlinkmelbourne.com.au/index.php","Metlink - Victoria\'s Official Public Transport Web site")
+ }
+ }
+
+ // NOTE: this is no longer used due to accessibility issues
+ function emailToFriend()
+ {
+ var url = escape("http://www.metlinkmelbourne.com.au/");
+
+ var width = 550;
+ var height = 500;
+ var leftPos = (screen.availWidth-width) / 2
+ var topPos = (screen.availHeight-height) / 2
+
+ // displays the image selector
+ emailWindow = window.open('/tools/email_to_friend.php?url=' + url,'imageWindow','toolbar=no,width=' + width + ',height=' + height + ',directories=no,status=no,scrollbars=yes,resize=yes,menubar=no,top=' + topPos + ',left=' + leftPos);
+ if(emailWindow != null && emailWindow.opener == null)
+ {
+ emailWindow.opener = window;
+ }
+ emailWindow.focus();
+ }
+
+ function swapText(show)
+ {
+ if (show == 'metro')
+ {
+ document.getElementById('metTag').style.display="block";
+ document.getElementById('vicTag').style.display="none";
+ document.getElementById('map').src = "images/metlink/mapBtn_met.gif";
+ }
+ else if (show == 'vic')
+ {
+ document.getElementById('metTag').style.display="none";
+ document.getElementById('vicTag').style.display="block";
+ document.getElementById('map').src = "images/metlink/mapBtn_vic.gif";
+ }
+ }
+
+ // --></script><script type="text/javascript" language="JavaScript">
+ // Date and Time Strings
+
+ var dayString = new Array ( "Sun",
+ "Mon",
+ "Tue",
+ "Wed",
+ "Thu",
+ "Fri",
+ "Sat");
+ var monthString = new Array ( "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December");
+ </script></head>
+<body onload="">
+<div id="wrapper">
+<div id="outer">
+<div id="headerMain" class="dontprint">
+<div id="header">
+<h1><a href="http://www.viclink.com.au" title="Viclink"><span>Viclink</span></a></h1>
+<div id="utilities">
+<ul>
+<li>
+<a href="http://www.metlinkmelbourne.com.au/myway" title="Log in to MyWay">Login</a>
+</li>
+<li>
+<a href="http://feedback.metlinkmelbourne.com.au/default.aspx">Feedback</a>
+</li>
+<li>
+<a href="http://store.metlinkmelbourne.com.au/metcard/store/">Buy online</a>
+</li>
+</ul>
+</div>
+<div id="utilities_search">
+<p class="byline">Your guide to public transport in Melbourne and Victoria</p>
+<ul>
+<li><a href="http://www.metlinkmelbourne.com.au/search" title="Search all content on this website">Search</a></li>
+</ul>
+</div>
+</div>
+<div id="mainNav">
+<ul>
+<li id="home" class="first"><a href="http://www.metlinkmelbourne.com.au"><span>Home</span></a></li>
+<li id="timetables"><a href="http://www.metlinkmelbourne.com.au/timetables"><span>Timetables</span></a></li>
+<li id="maps_stations_stops"><a href="http://www.metlinkmelbourne.com.au/maps_stations_stops"><span>Maps stations stops</span></a></li>
+<li id="fares_tickets"><a href="http://www.metlinkmelbourne.com.au/fares_tickets"><span>Fares &amp; tickets</span></a></li>
+<li id="using_public_transport"><a href="http://www.metlinkmelbourne.com.au/using_public_transport"><span>Using public transport</span></a></li>
+<li id="accessible_transport"><a href="http://www.metlinkmelbourne.com.au/accessible_transport"><span>Accessible transport</span></a></li>
+<li id="news"><a href="http://www.metlinkmelbourne.com.au/news"><span>News</span></a></li>
+<li id="about_metlink"><a href="http://www.metlinkmelbourne.com.au/about_metlink"><span>About Metlink</span></a></li>
+</ul>
+</div>
+<div id="subUtilities">
+<div id="journeyPlanner">
+<a href="http://jp.metlinkmelbourne.com.au/">Journey Planner</a>
+</div>
+</div>
+</div>
+<div id="container">
+<div id="clearheader"></div>
+<div class="outerwrap">
+<div class="printonly">
+<img src="images/metlink/metlink.gif" alt="Viclink"/>
+</div>
+<div style="float:left" class="outerwrap">
+<div id="centrecontent">
+<div id="content">
+<div class="section">
+<div class="top_right">
+<div class="top_left">
+<h1>Travel Plan</h1>
+<div class="bottom_right">
+<div class="bottom_left"></div>
+</div>
+</div>
+</div>
+<div class="sectionDescription"><!--Start MAIN-->
+<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
+<tbody>
+<tr>
+<td valign="top" width="100%">
+<a name="startcontent"/><!-- Table STARTS HERE -->
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+<tbody>
+<tr>
+<td valign="top" width="100%"><!-- Left -->
+<form method="post" action="XSLT_TRIP_REQUEST2" name="tripRequest" xmlns=""><input type="hidden" name="sessionID" value="VICWA06_732007765"><input type="hidden" name="language" value="en"><input type="hidden" name="requestID" value="1"><input type="hidden" name="command" value=""><input type="hidden" name="itdLPxx_view" value=""><input type="hidden" name="itdLPxx_soi" value=""><input type="hidden" name="itdLPxx_legTT" value=""><input type="hidden" name="tripSelection" value=""><input type="hidden" name="tripSelector1" value="1"><div id="JPContent"><div class="jpHeaderBox"><div class="jpHeaderBoxHdr"><h2 class="h2">Option 1</h2></div><div class="base"><div class="baseInner"><div class="jpHeaderBoxInner"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="55%"><div class="jpBold " style="float:left;">From: </div><div class="jpText">29-High St/Barkers Rd (Kew)</div><div style="clear:left;"></div><div class="jpBold " style="float:left;">To: </div><div class="jpText">Sunshine Railway Station (Sunshine)</div><div style="clear:left;"></div><div class="jpBold " style="float:left;">Fares: </div><div class="jpText">Zone(s) 1 <a target="_blank" href="http://www.metlinkmelbourne.com.au/fares-tickets/metropolitan-fares-and-tickets/metcard/metcard-types/">Metcard</a></div></td><td width="45%"><div class="jpBold " style="float:left;">Departing: </div><div class="jpText">8:39 pm, Mon 5
+ December
+ 2011 </div><div style="clear:left;"></div><div class="jpBold " style="float:left;">Arriving: </div><div class="jpText">9:42 pm, Mon 5
+ December
+ 2011 </div><div style="clear:left;"></div><div class="jpBold " style="float:left;">Total Time: </div><div class="jpText">1 hr 3 min </div></td></tr><tr><td colspan="2" class="error"></td></tr></table><br><table width="100%" border="0" cellpadding="2" cellspacing="2" text-align="top"><tr class="h3"><th width="12%" colspan="2">Travel by</th><th width="5%"></th><th width="8%">Time</th><th width="37%">Details</th><th width="8%">Map</th><th width="30%" colspan="2">Information</th></tr><tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/TramIcon30px.gif" alt="Metro Tram"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 8:39 pm</span></td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19742" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="29-Barkers Rd/High St (Kew)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19742" class="soi" target="_blank">29-Barkers Rd/High St (Kew)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C1.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p2_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Take the Route<strong> 109 tram towards Port Melbourne</strong></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 9 min<br>Zone(s): 1<br>Operator: Yarra Trams<br><br><a href="XSLT_TRIP_REQUEST2?language=en&amp;command=loadLegTT_1_1&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;tripSelection=on&amp;tripSelector1=1&amp;itdLPxx_view=detail&amp;itdLPxx_legTT=:1_1">Leg Timetable</a></td></tr><tr class="p2_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"><span>Mon, 8:48 pm</span></div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19732" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="19-North Richmond Railway Station/Victoria St (Richmond)" border="0" class="dontprint"></a></span>Get off at stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19732" class="soi" target="_blank">19-North Richmond Railway Station/Victoria St (Richmond)</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr><tr class="p3_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/WalkIcon30px.gif" alt="Walk"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"> </td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19732" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="19-North Richmond Railway Station/Victoria St (Richmond)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19732" class="soi" target="_blank">19-North Richmond Railway Station/Victoria St (Richmond)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C2.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p3_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Walk</td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 4 min<br></td></tr><tr class="p3_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"> </div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19977" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="North Richmond Railway Station (Richmond)" border="0" class="dontprint"></a></span><strong>To</strong><a href="http://www.metlinkmelbourne.com.au/stop/view/19977" class="soi" target="_blank"> North Richmond Railway Station (Richmond)</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr><tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/TrainIcon30px.gif" alt="Metro Train"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 8:52 pm</span></td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19977" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="North Richmond Railway Station (Richmond)" border="0" class="dontprint"></a></span><strong>From <a href="http://www.metlinkmelbourne.com.au/stop/view/19977" class="soi" target="_blank">North Richmond Railway Station (Richmond)</a><a href="http://www.metlinkmelbourne.com.au/stop/view/19977" class="soi" target="_blank"> Platform 1</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C3.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p2_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Take the<strong> train towards Parliament</strong></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 11 min<br>Frequency: 10 min<br>Zone(s): 1<br>Operator: Metro<br><br><a href="XSLT_TRIP_REQUEST2?language=en&amp;command=loadLegTT_1_3&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;tripSelection=on&amp;tripSelector1=1&amp;itdLPxx_view=detail&amp;itdLPxx_legTT=:1_3">Leg Timetable</a></td></tr><tr class="p2_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"><span>Mon, 9:03 pm</span></div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/22180" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="Southern Cross Railway Station (Melbourne City)" border="0" class="dontprint"></a></span>Get off at <a href="http://www.metlinkmelbourne.com.au/stop/view/22180" class="soi" target="_blank">Southern Cross Railway Station (Melbourne City) Platform 9</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr><tr class="p3_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/WalkIcon30px.gif" alt="Walk"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"> </td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/22180" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="Southern Cross Railway Station (Melbourne City)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/22180" class="soi" target="_blank">Southern Cross Railway Station (Melbourne City)</a><a href="http://www.metlinkmelbourne.com.au/stop/view/22180" class="soi" target="_blank"> Platform 9</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C4.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p3_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Walk</td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 6 min<br></td></tr><tr class="p3_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"> </div></td><td>To 1-Spencer St/Bourke St (Melbourne City)</td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr><tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/TramIcon30px.gif" alt="Metro Tram"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 9:09 pm</span></td><td width="37%"><strong>From Stop 1-Spencer St/Bourke St (Melbourne City)</strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C5.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p2_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Take the Route<strong> 86 tram towards City (Docklands)</strong></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 2 min<br>Zone(s): 1<br>Operator: Yarra Trams<br><br><a href="XSLT_TRIP_REQUEST2?language=en&amp;command=loadLegTT_1_5&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;tripSelection=on&amp;tripSelector1=1&amp;itdLPxx_view=detail&amp;itdLPxx_legTT=:1_5">Leg Timetable</a></td></tr><tr class="p2_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"><span>Mon, 9:11 pm</span></div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/18190" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="119-La Trobe St/Spencer St (Melbourne City)" border="0" class="dontprint"></a></span>Get off at stop <a href="http://www.metlinkmelbourne.com.au/stop/view/18190" class="soi" target="_blank">119-La Trobe St/Spencer St (Melbourne City)</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr><tr class="p3_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/WalkIcon30px.gif" alt="Walk"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"> </td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/18190" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="119-La Trobe St/Spencer St (Melbourne City)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/18190" class="soi" target="_blank">119-La Trobe St/Spencer St (Melbourne City)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C6.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p3_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Walk</td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 3 min<br></td></tr><tr class="p3_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"> </div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19510" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="Jeffcott St/Spencer St (West Melbourne)" border="0" class="dontprint"></a></span><strong>To</strong><a href="http://www.metlinkmelbourne.com.au/stop/view/19510" class="soi" target="_blank"> Jeffcott St/Spencer St (West Melbourne)</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr><tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/BusIcon30px.gif" alt="Metro/Regional Bus"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 9:14 pm</span></td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19510" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="Jeffcott St/Spencer St (West Melbourne)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19510" class="soi" target="_blank">Jeffcott St/Spencer St (West Melbourne)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C7.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p2_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Take the Route<strong> 219 bus towards Sunshine Park</strong></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 28 min<br>Zone(s): 1<br>Operator: Melbourne Bus Link<br><br><a href="XSLT_TRIP_REQUEST2?language=en&amp;command=loadLegTT_1_7&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;tripSelection=on&amp;tripSelector1=1&amp;itdLPxx_view=detail&amp;itdLPxx_legTT=:1_7">Leg Timetable</a></td></tr><tr class="p2_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"><span>Mon, 9:42 pm</span></div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/18766" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="Sunshine Railway Station/Dickson St (Sunshine)" border="0" class="dontprint"></a></span>Get off at stop <a href="http://www.metlinkmelbourne.com.au/stop/view/18766" class="soi" target="_blank">Sunshine Railway Station/Dickson St (Sunshine) Platform Bay 10</a></td><td style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C8.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2"></td></tr></table><table width="100%" border="0" class="dontprint"><tr><td width="38%"><a href="XSLT_TRIP_REQUEST2?language=en&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;command=changeRequest&amp;itdLPxx_view=advanced&amp;itdLPxx_emailAddress_origin=invalid&amp;itdLPxx_emailAddress_destination=invalid"><img src="images/metlink/jp/modify.gif" alt="Modify" border="0"></a> <a href="XSLT_TRIP_REQUEST2?language=en&amp;itdLPxx_view=advanced"><img src="images/metlink/jp/searchagain.gif" alt="Search Again" border="0"></a></td><td width="62%"><div align="right"><a href="XSLT_TRIP_REQUEST2?language=en&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;command=tripRetoure&amp;itdLPxx_day=5&amp;itdLPxx_year=2011&amp;itdLPxx_month=12&amp;itdLPxx_hour=9&amp;itdLPxx_minute=42&amp;itdLPxx_ampm=pm&amp;itdLPxx_view=advanced&amp;itdLPxx_emailAddress_origin=invalid&amp;itdLPxx_emailAddress_destination=invalid"><img src="images/metlink/jp/return.gif" alt="Return Journey" width="121" height="23" border="0"></a> <a href="XSLT_TRIP_REQUEST2?language=en&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;command=tripGoOn&amp;itdLPxx_view=advanced&amp;itdLPxx_day=5&amp;itdLPxx_year=2011&amp;itdLPxx_month=12&amp;itdLPxx_hour=9&amp;itdLPxx_minute=42&amp;itdLPxx_ampm=pm&amp;itdLPxx_emailAddress_origin=invalid"><img src="images/metlink/jp/onward.gif" alt="Onward Journey" width="121" height="23" border="0"></a></div></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td width="12%"><p class="jpBold">Legend</p></td><td width="11%" align="center"><img src="images/metlink/means/TrainIcon30px.gif" alt="Metro Train"></td><td width="11%" align="center"><img src="images/metlink/means/TramIcon30px.gif" alt="Metro Tram"></td><td width="11%" align="center"><img src="images/metlink/means/BusIcon30px.gif" alt="Metro/Regional Bus"></td><td width="11%" align="center"><img src="images/metlink/means/RegionalTrainIcon30px.gif" alt="V/Line Train"></td><td width="11%" align="center"><img src="images/metlink/means/RegionalBusIcon30px.gif" alt="V/Line Coach"></td><td width="11%" align="center"><img src="images/metlink/means/WalkIcon30px.gif" alt="Walk"></td><td width="11%" align="center"><img src="images/metlink/means/CarIcon30px.gif" alt="Car"></td><td width="11%" align="center"><img src="images/metlink/means/CycleIcon30px.gif" alt="Cycle"></td></tr><tr><td> </td><td><p class="legend">Metro<br>Train</p></td><td><p class="legend">Metro<br>Tram</p></td><td><p class="legend">Metro/Regional<br>Bus</p></td><td><p class="legend">V/Line<br>Train</p></td><td><p class="legend">V/Line<br>Coach</p></td><td><p class="legend">Walk<br></p></td><td><p class="legend">Car<br></p></td><td><p class="legend">Cycle<br></p></td></tr></table><table width="100%" border="0" cellpadding="2" cellspacing="0"><tr><td width="12%"><p><strong><a href="http://www.metlinkmelbourne.com.au/fares-tickets/metropolitan-fares-and-tickets/metropolitan-zones/" target="_blank">Zones</a></strong></p></td><td width="15%"><p class="legend">1 = Zone 1</p></td><td width="14%"><p class="legend">2 = Zone 2</p></td><td width="16%"><p class="legend">C = City Saver</p></td><td width="15%"><p class="legend">V = V/Line</p></td><td width="28%"></td></tr></table><p class="dontprint"><a href="XSLT_TRIP_REQUEST2?language=en&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;language=en&amp;command=nop&amp;itdLPxx_view=advanced"><img src="images/metlink/jp/goback.gif" alt="Go Back" width="69" height="17" border="0"></a></p><p class="jpText dontprint">Haven't found what you're looking for? <a target="_blank" href="http://www.metlinkmelbourne.com.au/timetables/journey-planner-faqs/">Check the journey planner frequently asked questions.</a></p><span class="printonly" style="width:90%"><br><p class="jpText"><strong>Disclaimer</strong><br><br>The information provided by this Website is subject to change without notice, and is provided to you without warranties of any kind, either express or implied, subject to any consumer legislation. Please call the Metlink Call Centre on 131 638 prior to travel for the most up to date information available in relation to your required services.</p></span></div></div></div></div></div></form>
+</td>
+</tr>
+</tbody>
+</table>
+</td>
+</tr>
+</tbody>
+</table><!--End MAIN-->
+</div>
+<div id="sectionChildren"/>
+</div>
+</div>
+</div>
+</div>
+<div id="left">
+<div id="subNav">
+<h1></h1>
+<div class="dontprint" xmlns="">
+<ul>
+<li class="first"><a href="javascript:var wnd = open('WebHelp/en/Metlink_Journey_Planner.htm#Travel_Plan.htm', 'helpWnd', 'scrollbars=yes,resizable=yes');">What's on this page?</a></li>
+<li><a href="javascript:var wnd = open('WebHelp/en/Metlink_Journey_Planner.htm#Step_1_enter_your_origin_and_destination.htm', 'helpWnd', 'scrollbars=yes,resizable=yes');">Getting started</a></li>
+<li><a href="javascript:var wnd = open('WebHelp/en/Metlink_Journey_Planner.htm#Helpful_Tips.htm', 'helpWnd', 'scrollbars=yes,resizable=yes');">Helpful tips</a></li>
+<li class="last"><a href="http://feedback.metlinkmelbourne.com.au/default.aspx?usage=JP&amp;url=http:%2F%2Fjp.metlinkmelbourne.com.au%2Fmetlink%2FXSLT_TRIP_REQUEST2%3FsessionID%3D0%26requestID%3D0%26name_origin%3D10002451%26type_origin%3DstopID%26name_destination%3D10001218%26type_destination%3DstopID%26itdDate%3D20111205%26itdTime%3D2050%26itdTripDateTimeDepArr%3Ddep%26ptOptionsActive%3D1%26includedMeans%3Dcheckbox%26inclMOT_0%3Don%26inclMOT_1%3Don%26inclMOT_2%3Don%26inclMOT_3%3Don%26inclMOT_4%3Don%26inclMOT_5%3Don%26inclMOT_6%3Don%26inclMOT_7%3Don%26inclMOT_8%3Don%26inclMOT_10%3Don%26changeSpeed%3Dnormal%26routeType%3DLEASTTIME%26imparedOptionsActive%3D1%26wheelchair%3D0%26noSolidStairs%3D0%26itOptionsActive%3D1%26trITDepMOT%3D100%26trITDepMOTvalue%3D10%26trITArrMOT%3D100%26trITArrMOTvalue%3D10%26useProxFootSearch%3D1%26" target="_blank">Customer feedback</a></li>
+</ul>
+<div class="naviBoxHead">
+<h1></h1>
+<div class="naviBox">
+<div class="printLink"><a href="javascript:window.print();">Print Page</a></div>
+<div class="emailafriendLink"><a href="XSLT_TRIP_REQUEST2?language=en&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;command=nop&amp;itdLPxx_view=mailAFriend:1&amp;itdLPxx_emailAddress_origin=invalid&amp;itdLPxx_emailAddress_destination=invalid">Email a friend</a></div>
+<div>
+<form method="post" action="http://www.metlinkmelbourne.com.au/bookmark/action"><input type="hidden" name="type" value="jpjourney"><input type="hidden" name="data" value="http://jp.metlinkmelbourne.com.au/metlink/XSLT_TRIP_REQUEST2?sessionID=0&amp;type_origin=stopID&amp;name_origin=10002451&amp;type_destination=stopID&amp;name_destination=10001218"><input type="hidden" name="default_label" value="Bookmark Label"><input type="hidden" name="redirectURL" value="http://jp.metlinkmelbourne.com.au/metlink/XSLT_TRIP_REQUEST2?sessionID=VICWA06_732007765&amp;requestID=1&amp;itdLPxx_view=overview"><input type="text" size="20" name="user_label" value="Bookmark Label">
+
+ <input type="submit" value="Add to My Way" name="AddBookmarkButton"></form>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="right" class="dontprint">
+<div class="right_inner">
+<div id="toolbar-right">
+<div class="CMSBoxSeparator" xmlns="">
+<div class="CMSBox">
+<div class="CMSBoxContent">
+<h1>Service alterations</h1><div class="CMSBoxContentInner">
+<div class="rightICS">
+<table class="ics" cellspacing="0" cellpadding="0">
+<tr>
+<td>
+<div>
+<div style="float:left;"><img src="images/metlink/means/TrainIcon30px.gif" alt="Metro Train"> </div>Metropolitan trains<br><img src="images/metlink/jp/advanced.gif"> <a target="_blank" href="http://www.metlinkmelbourne.com.au/news/service-alterations/metropolitan-trains/extra-trains-for-melbourne-victory-v-adelaide-united-a-league-match-saturday-10-december-2011/">Extra trains for Melbourne Victory v Adelaide United A-League match: Saturday, 10 December 2011</a><br><br></div>
+<div style="clear:both"></div>
+<div>
+<div style="float:left;"> </div>Regional general<br><img src="images/metlink/jp/advanced.gif"> <a target="_blank" href="http://www.viclink.com.au/off-peak-fares-not-available-for-any-journey-between-southern-cross-and-zone-b-stations-and-stops/">Off-peak fares not available for any journey between Southern Cross and Zone B stations and stops</a><br><br></div>
+<div style="clear:both"></div>
+<div>
+<div style="float:left;"> </div>Metropolitan trains<br><img src="images/metlink/jp/advanced.gif"> <a target="_blank" href="http://www.metlinkmelbourne.com.au/news/news-promotions/epping-station-car-park-and-pedestrian-access-of-the-eastern-side-closure-from-thursday-6-january-2011">Epping Station car park and pedestrian access of the eastern side closure from Thursday, 6 January 2011</a><br><br></div>
+<div style="clear:both"></div>
+<div>
+<div style="float:left;"><img src="images/metlink/means/NonVLineIcon30px.gif" alt="Non-V/Line Interstate Services"> </div>Regional trains<br><br></div>
+<div style="clear:both"></div>
+<div>
+<div style="float:left;"> </div>Metropolitan trams<br><img src="images/metlink/jp/advanced.gif"> <a target="_blank" href="http://www.metlinkmelbourne.com.au/news/service-alterations/metropolitan-trams/temporary-closure-of-stop-24-on-route-59-to-airport-west-only-until-further-notice">Temporary closure of Stop 24 on Route 59 (to Airport West only): until further notice</a><br><br></div>
+<div style="clear:both"></div><br><img src="images/metlink/jp/advanced.gif"> <a href="http://www.metlinkmelbourne.com.au/news/service-alterations/">More service alterations</a></td>
+</tr>
+</table>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="CMSBoxSeparator" xmlns="">
+<div class="CMSBox">
+<div class="CMSBoxContent">
+<h1>Announcements</h1><div class="CMSBoxContentInner">
+<div class="rightICS">
+<table class="ics" cellspacing="0" cellpadding="0">
+<tr>
+<td><img src="images/metlink/jp/advanced.gif"> <a href="http://www.metlinkmelbourne.com.au/news/">More announcements</a></td>
+</tr>
+</table>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="CMSBoxSeparator" xmlns="">
+<div class="CMSBox">
+<div class="CMSBoxContent">
+<h1>Hints and Tips</h1><div class="CMSBoxContentInner">
+<div class="rightICS">
+<table class="ics" cellspacing="0" cellpadding="0"></table>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="clearfooter"></div>
+</div>
+<div id="footer" class="dontprint">
+<ul>
+<li class="first"><a href="http://feedback.metlinkmelbourne.com.au/default.aspx">Feedback</a></li>
+<li><a href="http://www.metlinkmelbourne.com.au/footer/legal_disclaimer">Legal Disclaimer</a></li>
+<li><a href="http://www.metlinkmelbourne.com.au/footer/privacy_policy">Privacy Policy</a></li>
+<li><a href="http://www.metlinkmelbourne.com.au/footer/copyright">Copyright</a></li>
+<li><a href="http://www.metlinkmelbourne.com.au/footer/w3c_accessibility">W3C Accessibility</a></li>
+<li class="last"><a href="http://www.metlinkmelbourne.com.au/footer/sitemap">Sitemap</a></li>
+</ul>
+<ul id="Credits">
+<li class="designIT"><a href="http://www.designit.com.au" target="_blank"><span>Developed by designIT</span></a></li>
+<li class="eZpublish"><a href="http://www.ez.no/" target="_blank" class="last"><span>Powered by eZ Publish</span></a></li>
+</ul>
+<div id="footerDesc">
+<p>© 2007</p>
+</div>
+</div>
+<script language="JavaScript" type="text/javascript"><!--
+ var _rsCI="vic-metlink";
+ var _rsCG="0";
+ var _rsDT=0;
+ var _rsDU=0;
+ var _rsDO=0;
+ var _rsX6=0;
+ var _rsSI=escape(window.location);
+ var _rsLP=location.protocol.indexOf('https')>-1?'https:':'http:';
+ var _rsRP=escape(document.referrer);
+ var _rsND=_rsLP+'//secure-au.imrworldwide.com/';
+ if (parseInt(navigator.appVersion)>=4) {
+ var _rsRD=(new Date()).getTime();
+ var _rsSE=0;
+ var _rsSV="";
+ var _rsSM=0;
+ _rsCL='<scr'+'ipt language="JavaScript" type="text/javascript" src="'+_rsND+'v51.js"><\/scr'+'ipt>';
+ }
+ else{
+ _rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&cg='+_rsCG+'&si='+_rsSI+'&rp='+_rsRP+'">';
+ }
+ document.write(_rsCL);
+ // -->
+</script>
+<noscript>
+<img src="https://secure-au.imrworldwide.com/cgi-bin/m?ci=vic-metlink&amp;cg=0" alt=""/>
+</noscript>
+</div>
+</body>
+</html>
View
3  spec/fixtures/tram_snippet.html
@@ -0,0 +1,3 @@
+<table width="100%" border="0" cellpadding="2" cellspacing="2" text-align="top"><tr class="h3"><th width="12%" colspan="2">Travel by</th><th width="5%"></th><th width="8%">Time</th><th width="37%">Details</th><th width="8%">Map</th><th width="30%" colspan="2">Information</th></tr><tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/TramIcon30px.gif" alt="Metro Tram"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 8:39 pm</span></td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19742" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="29-Barkers Rd/High St (Kew)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19742" class="soi" target="_blank">29-Barkers Rd/High St (Kew)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C1.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
+
+ </td></tr><tr class="p2_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Take the Route<strong> 109 tram towards Port Melbourne</strong></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 9 min<br>Zone(s): 1<br>Operator: Yarra Trams<br><br><a href="XSLT_TRIP_REQUEST2?language=en&amp;command=loadLegTT_1_1&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;tripSelection=on&amp;tripSelector1=1&amp;itdLPxx_view=detail&amp;itdLPxx_legTT=:1_1">Leg Timetable</a></td></tr><tr class="p2_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"><span>Mon, 8:48 pm</span></div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19732" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="19-North Richmond Railway Station/Victoria St (Richmond)" border="0" class="dontprint"></a></span>Get off at stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19732" class="soi" target="_blank">19-North Richmond Railway Station/Victoria St (Richmond)</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr>
View
3  spec/spec_helper.rb
@@ -0,0 +1,3 @@
+$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'metlinkr'
View
21 spec/step_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe Metlinkr::Step do
+ describe '#parse' do
+ let(:tram_snippet) do
+ File.read(File.dirname(__FILE__) + "/fixtures/tram_snippet.html")
+ end
+
+ let(:row_set) do
+ Nokogiri::HTML(tram_snippet).xpath("//tr")
+ end
+
+ subject do
+ Metlinkr::Step.parse(row_set)
+ end
+
+ it "parses the mode of transport" do
+ subject.method.should == :tram
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.