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

#initialize(options, arguments, command) ⇒ CommandRunner

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


23
24
25
26
27
# File 'lib/cri/command_runner.rb', line 23

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

Instance Attribute Details

#argumentsArray (readonly)

Returns The list of arguments.

Returns:

  • (Array)

    The list of arguments


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

def arguments
  @arguments
end

#commandCommand (readonly)

Returns The command.

Returns:


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

def command
  @command
end

#optionsHash (readonly)

Returns A hash contain the options and their values.

Returns:

  • (Hash)

    A hash contain the options and their values


8
9
10
# File 'lib/cri/command_runner.rb', line 8

def options
  @options
end

Instance Method Details

#callvoid

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
  run
end

#runvoid

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