Class: Yap::Shell::CommandFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/yap/shell/commands.rb

Class Method Summary collapse

Class Method Details

.build_command_for(world:, command:, args:, heredoc:, internally_evaluate:, line:) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yap/shell/commands.rb', line 10

def self.build_command_for(world:, command:, args:, heredoc:, internally_evaluate:, line:)
  return RubyCommand.new(world:world, str:command) if internally_evaluate

  case command
  when ShellCommand then ShellCommand.new(world:world, str:command, args:args, heredoc:heredoc, line:line)
  when BuiltinCommand then BuiltinCommand.new(world:world, str:command, args:args, heredoc:heredoc)
  when FileSystemCommand then FileSystemCommand.new(world:world, str:command, args:args, heredoc:heredoc)
  else
    UnknownCommand.new(world:world, str:command, args:args, heredoc:heredoc)
  end
end