Class: Command::BasicCommand Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/command/basic_command.rb

Overview

This class is abstract.

Subclass and override #exec to implement.

Author:

  • tnoguer

Direct Known Subclasses

AmbariCommand, CrowbarCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver, logger = nil) ⇒ BasicCommand (private)

Default constructor.

Parameters:

Raises:

  • (ArgumentError)

    if the type of receiver is not correct.



28
29
30
31
32
33
# File 'lib/command/basic_command.rb', line 28

def initialize(receiver, logger = nil)
  @receiver = receiver
  @logger = logger
  @logger = Common::CloudboxLoggerMock.new if @logger.nil?
  @logger.info("Command::BasicCommand   initialize the parameters...")
end

Instance Attribute Details

#loggerObject (protected)

This attribute is the logger.



16
17
18
# File 'lib/command/basic_command.rb', line 16

def logger
  @logger
end

#receiverObject (protected)

This attribute is the receiver, which will receive executed command.



14
15
16
# File 'lib/command/basic_command.rb', line 14

def receiver
  @receiver
end

Instance Method Details

#execObject

Note:

This method has to be overrided by the inheriting class.

The execution of the command.

Raises:

  • (NotImplementedError)

    When the method is not overrided by the inheriting class.

Author:

  • tnoguer



40
41
42
# File 'lib/command/basic_command.rb', line 40

def exec()
  raise NotImplementedError
end