Permalink
Browse files

Parsing duration (badly)

  • Loading branch information...
1 parent c20583d commit 7240db7893e375d5f1cd167a87323792f4fe7d80 @chendo committed Dec 5, 2011
Showing with 9 additions and 0 deletions.
  1. +6 −0 lib/metlinkr/step.rb
  2. +3 −0 spec/step_spec.rb
@@ -16,6 +16,7 @@ def parse(row_set)
parse_route
parse_departure_time
parse_arrival_time
+ parse_duration
self
end
@@ -50,6 +51,11 @@ def parse_arrival_time
@arrival_time = clean_time(@row_set[2].xpath("td/div/span").first.content)
end
+ def parse_duration
+ @row_set[1].xpath("td").last.content.match(/Time (\d+ min)/)
+ @duration = $1
+ end
+
def clean_stop_name(stop)
stop.gsub!(/(\d+)-/, 'Stop \1 - ').strip
end
View
@@ -38,5 +38,8 @@
subject.arrival_time.should == "8:48pm"
end
+ it "parses the duration" do
+ subject.duration.should == "9 min"
+ end
end
end

0 comments on commit 7240db7

Please sign in to comment.