Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Parsing the departure and arrival time

  • Loading branch information...
commit c20583dcaf1fa7359d6ec28e3947bd9f0cf3dd7b 1 parent c84ec33
@chendo authored
Showing with 24 additions and 0 deletions.
  1. +15 −0 lib/metlinkr/step.rb
  2. +9 −0 spec/step_spec.rb
View
15 lib/metlinkr/step.rb
@@ -14,6 +14,8 @@ def parse(row_set)
parse_origin
parse_destination
parse_route
+ parse_departure_time
+ parse_arrival_time
self
end
@@ -39,8 +41,21 @@ def parse_route
@route = @row_set[1].xpath("td/strong").first.content.strip
end
+ def parse_departure_time
+ @departure_time = clean_time(@row_set[0].xpath("td/span").first.content)
+ end
+
+ def parse_arrival_time
+ # Why the FUCK is that div there?
+ @arrival_time = clean_time(@row_set[2].xpath("td/div/span").first.content)
+ end
+
def clean_stop_name(stop)
stop.gsub!(/(\d+)-/, 'Stop \1 - ').strip
end
+
+ def clean_time(time)
+ time.gsub(/^.*,/, '').gsub(' ', '').strip
+ end
end
end
View
9 spec/step_spec.rb
@@ -29,5 +29,14 @@
it "parses the route" do
subject.route.should == '109 tram towards Port Melbourne'
end
+
+ it "parses the departure time" do
+ subject.departure_time.should == "8:39pm"
+ end
+
+ it "parses the arrival time" do
+ subject.arrival_time.should == "8:48pm"
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.