Class: Cri::CommandRunner

Inherits:
Object
  • Object
show all
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)

Instance Method Summary (collapse)

Constructor Details

- (CommandRunner) initialize(options, arguments, command)

Creates a command runner from the given options, arguments and command.

Parameters:

  • options (Hash)

    A hash contain the options and their values

  • arguments (Array)

    The list of arguments

  • command (Cri::Command)

    The Cri command



25
26
27
28
29
# File 'lib/cri/command_runner.rb', line 25

def initialize(options, arguments, command)
  @options   = options
  @arguments = arguments
  @command   = command
end

Instance Attribute Details

- (Array) arguments (readonly)

Returns The list of arguments

Returns:

  • (Array)

    The list of arguments



13
14
15
# File 'lib/cri/command_runner.rb', line 13

def arguments
  @arguments
end

- (Command) command (readonly)

Returns The command

Returns:



16
17
18
# File 'lib/cri/command_runner.rb', line 16

def command
  @command
end

- (Hash) options (readonly)

Returns A hash contain the options and their values

Returns:

  • (Hash)

    A hash contain the options and their values



10
11
12
# File 'lib/cri/command_runner.rb', line 10

def options
  @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.



35
36
37
# File 'lib/cri/command_runner.rb', line 35

def call
  self.run
end

- (void) run

This method is abstract.

This method returns an undefined value.

Performs the actual execution of the command.



44
45
46
# File 'lib/cri/command_runner.rb', line 44

def run
  raise NotImplementedError, 'Cri::CommandRunner subclasses must implement #run'
end