lib/robot/commands/factory.rb in robot_rea-0.1.5 vs lib/robot/commands/factory.rb in robot_rea-0.1.6

- old
+ new

@@ -1,11 +1,13 @@ +# 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] + COMMANDS = [Left, Right, Move, Place, Report, NoOp].freeze class Factory def self.build(command) command_klass = COMMANDS.detect { |klass| klass.matches?(command) } command_klass