Commit 6c713fa
Changed files (3)
spec
features
lib/move_forward.rb
@@ -2,12 +2,26 @@ class MoveForward
def initialize(rover)
@rover = rover
end
- def run(instruction)
- if matches(instruction)
- @rover.drive
- end
+ def run
+ @rover.drive
+ end
+end
+
+class FilteredCommand
+ def initialize(command, specification)
+ @command = command
+ @specification = specification
+ end
+ def run(item)
+ @command.run if @specification.matches(item)
+ end
+end
+
+class Specification
+ def initialize(criteria)
+ @criteria = criteria
end
def matches(item)
- 'M' == item.upcase
+ @criteria.call(item)
end
end