Class: Cri::CommandRunner
- Inherits:
-
Object
- Object
- Cri::CommandRunner
- Defined in:
- lib/cri/command_runner.rb
Overview
A command runner is responsible for the execution of a command. Using it is optional, but it is useful for commands whose execution block is large.
Instance Attribute Summary (collapse)
-
- (Array) arguments
readonly
The list of arguments.
-
- (Command) command
readonly
The command.
-
- (Hash) options
readonly
A hash contain the options and their values.
Instance Method Summary (collapse)
-
- (void) call
Runs the command.
-
- (CommandRunner) initialize(options, arguments, command)
constructor
A new instance of CommandRunner.
-
- (void) run
abstract
Performs the actual execution of the command.
Constructor Details
- (CommandRunner) initialize(options, arguments, command)
A new instance of CommandRunner
23 24 25 26 27 |
# File 'lib/cri/command_runner.rb', line 23 def initialize(, arguments, command) @options = @arguments = arguments @command = command end |
Instance Attribute Details
- (Array) arguments (readonly)
The list of arguments
13 14 15 |
# File 'lib/cri/command_runner.rb', line 13 def arguments @arguments end |
- (Command) command (readonly)
The command
16 17 18 |
# File 'lib/cri/command_runner.rb', line 16 def command @command end |
- (Hash) options (readonly)
A hash contain the options and their values
10 11 12 |
# File 'lib/cri/command_runner.rb', line 10 def @options end |
Instance Method Details
- (void) call
This method returns an undefined value.
Runs the command. By default, this simply does the actual execution, but subclasses may choose to add error handling around the actual execution.
33 34 35 |
# File 'lib/cri/command_runner.rb', line 33 def call self.run end |
- (void) run
This method is abstract.
This method returns an undefined value.
Performs the actual execution of the command.
42 43 44 |
# File 'lib/cri/command_runner.rb', line 42 def run raise NotImplementedError, 'Cri::CommandRunner subclasses must implement #run' end |