Module: Brandish::Processor::Block

Overview

A block processor. This is designed to act over a base to modify one specific block. The block name itself is specified on the class, and the class provides logic to only modify block nodes with the same name.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Ruby hook.



15
16
17
18
# File 'lib/brandish/processor/block.rb', line 15

def self.included(base)
  base.include Processor::NameFilter
  base.include Processor::PairFilter
end

Instance Method Details

#perform::Object

This method is abstract.

Performs the command adjustment. This must be subclassed and overwritten.

Returns:

  • (::Object)


42
43
44
# File 'lib/brandish/processor/block.rb', line 42

def perform
  fail NotImplementedError, "Please implement #{self.class}#perform"
end

#process_block(node) ⇒ ::Object

Processes the block. If the node's name doesn't match the name for this class, it passes it on up to Brandish::Processor::Base#process_block; otherwise, it passes it over to #perform.

Parameters:

Returns:

  • (::Object)


26
27
28
29
30
31
32
33
34
35
# File 'lib/brandish/processor/block.rb', line 26

def process_block(node)
  return super unless allowed_names.include?(node.name)
  @node = node
  @name = node.name
  @pairs = node.pairs
  @body = node.body

  assert_valid_pairs
  perform
end