Class: Tr3llo::BoardCommandFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/3llo/board_command_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(subcommand, args) ⇒ BoardCommandFactory

Returns a new instance of BoardCommandFactory.



7
8
9
10
# File 'lib/3llo/board_command_factory.rb', line 7

def initialize(subcommand, args)
  @subcommand = subcommand
  @args = args
end

Instance Method Details

#factoryObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/3llo/board_command_factory.rb', line 12

def factory
  case subcommand.to_sym
  when :list
    user_id = $container.resolve(:user)[:id]
    Command::Board::ListCommand.new(user_id)
  when :select
    board_id, _ = args
    Command::Board::SelectCommand.new(board_id)
  else
    Command::Board::InvalidCommand.new
  end
end