Sha256: 99f1ec8021e6035f54fc52141ffa434889429c64ec1f691a85b07438a42e5584
Contents?: true
Size: 516 Bytes
Versions: 2
Compression:
Stored size: 516 Bytes
Contents
# Factory class that takes a command input and returns the command object that can handle it, # this is used instead of if/else or case/when for each command. # If the command entered does not match any known command, the NoOp Command will be returned. module Robot module Commands COMMANDS = [Left, Right, Move, Place, Report, NoOp] class Factory def self.build(command) command_klass = COMMANDS.detect { |klass| klass.matches?(command) } command_klass end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
robot_rea-0.1.5 | lib/robot/commands/factory.rb |
robot_rea-0.1.4 | lib/robot/commands/factory.rb |