Sha256: daaff6fe2ad2bd6cd5d151341561395e43638753c9fb5a2029207f3ae1e2325f
Contents?: true
Size: 554 Bytes
Versions: 4
Compression:
Stored size: 554 Bytes
Contents
# frozen_string_literal: true # 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].freeze class Factory def self.build(command) command_klass = COMMANDS.detect { |klass| klass.matches?(command) } command_klass end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
robot_rea-0.1.9 | lib/robot/commands/factory.rb |
robot_rea-0.1.8 | lib/robot/commands/factory.rb |
robot_rea-0.1.7 | lib/robot/commands/factory.rb |
robot_rea-0.1.6 | lib/robot/commands/factory.rb |