Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Parsing duration (badly)

  • Loading branch information...
commit 7240db7893e375d5f1cd167a87323792f4fe7d80 1 parent c20583d
@chendo authored
Showing with 9 additions and 0 deletions.
  1. +6 −0 lib/metlinkr/step.rb
  2. +3 −0  spec/step_spec.rb
View
6 lib/metlinkr/step.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
3  spec/step_spec.rb
@@ -38,5 +38,8 @@
subject.arrival_time.should == "8:48pm"
end
+ it "parses the duration" do
+ subject.duration.should == "9 min"
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.