Class: KBuilder::Commands::BaseCommand

Inherits:
Object
  • Object
show all
Includes:
KLog::Logging
Defined in:
lib/k_builder/commands/base_command.rb

Overview

Base command for single responsibility actions that can be fired from methods in the builder.

Uses the command pattern

Direct Known Subclasses

CodeSyntaxHighlighterCommand, RuboCopCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ BaseCommand

Returns a new instance of BaseCommand.



15
16
17
18
# File 'lib/k_builder/commands/base_command.rb', line 15

def initialize(**opts)
  @builder = opts[:builder]
  @valid = true
end

Instance Attribute Details

#builderObject

Returns the value of attribute builder.



12
13
14
# File 'lib/k_builder/commands/base_command.rb', line 12

def builder
  @builder
end

#validObject

Returns the value of attribute valid.



13
14
15
# File 'lib/k_builder/commands/base_command.rb', line 13

def valid
  @valid
end

Instance Method Details

#debug(title: nil) ⇒ Object



30
31
32
33
# File 'lib/k_builder/commands/base_command.rb', line 30

def debug(title: nil)
  log.section_heading(title) if title
  debug_values if respond_to?(:debug_values)
end

#guard(message) ⇒ Object



20
21
22
23
24
# File 'lib/k_builder/commands/base_command.rb', line 20

def guard(message)
  # THIS SHOULD ONLY LOG IF DEBUGGING IS TURNED ON
  log.error(message)
  @valid = false
end

#valid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/k_builder/commands/base_command.rb', line 26

def valid?
  @valid
end