Skip to content
Browse files

Fixed duration parsing

  • Loading branch information...
1 parent 513676c commit 10cebea36df2e9195f3a2ec31584e544a412c1cc @chendo committed Jan 7, 2012
Showing with 4 additions and 3 deletions.
  1. +3 −1 lib/metlinkr/journey.rb
  2. +1 −2 lib/metlinkr/step.rb
View
4 lib/metlinkr/journey.rb
@@ -7,7 +7,7 @@ class Journey
START_URL = "http://jp.metlinkmelbourne.com.au/metlink/XSLT_TRIP_REQUEST2?language=en&itdLPxx_view=advanced"
- attr_reader :from, :to, :options, :trips
+ attr_reader :from, :to, :options, :trips, :url
def initialize(from, to, options = nil)
@from = from
@@ -45,6 +45,8 @@ def plan
doc = Nokogiri::HTML(body)
+ @from, @to = doc.search('div.jpHeaderBoxInner div.jpText').map { |node| node.content.gsub(/[^a-zA-Z\(\) \d-]/, '').strip }
+
links = doc.search('tr.p4 td.dontprint a, tr.p2 td.dontprint a')
links.shift if options[:ignore_earlier_trip]
View
3 lib/metlinkr/step.rb
@@ -62,8 +62,7 @@ def parse_arrival_time
end
def parse_duration
- @row_set[1].xpath("td").last.content.match(/Time (\d+ min)/)
- @duration = $1
+ @duration = @row_set[1].xpath("td").last.content.match(/(\d+ min)/)[1]
end
def clean_stop_name(stop)

0 comments on commit 10cebea

Please sign in to comment.
Something went wrong with that request. Please try again.