Permalink
Browse files

Added destination and refactored it a bit

  • Loading branch information...
1 parent 03e8dec commit 834bfb939561f5f61595f66438023d06d5954655 @chendo committed Dec 5, 2011
Showing with 14 additions and 2 deletions.
  1. +10 −2 lib/metlinkr/step.rb
  2. +4 −0 spec/step_spec.rb
View
@@ -12,6 +12,7 @@ def parse(row_set)
parse_method
parse_origin
+ parse_destination
self
end
@@ -26,8 +27,15 @@ def parse_method
end
def parse_origin
- @origin = @row_set[0].xpath("td/strong/a").first.content
- @origin.gsub!(/(\d+)-/, 'Stop \1 - ')
+ @origin = clean_stop_name(@row_set[0].xpath("td/strong/a").first.content)
+ end
+
+ def parse_destination
+ @destination = clean_stop_name(@row_set[2].xpath("td/a").first.content)
+ end
+
+ def clean_stop_name(stop)
+ stop.gsub!(/(\d+)-/, 'Stop \1 - ')
end
end
end
View
@@ -21,5 +21,9 @@
it "parses the origin name" do
subject.origin.should == "Stop 29 - Barkers Rd/High St (Kew)"
end
+
+ it "parses the destination name" do
+ subject.destination.should == "Stop 19 - North Richmond Railway Station/Victoria St (Richmond)"
+ end
end
end

0 comments on commit 834bfb9

Please sign in to comment.