Module: Brandish::Processor

Defined in:
lib/brandish/processor.rb,
lib/brandish/processor/base.rb,
lib/brandish/processor/block.rb,
lib/brandish/processor/inline.rb,
lib/brandish/processor/command.rb,
lib/brandish/processor/context.rb,
lib/brandish/processor/descend.rb,
lib/brandish/processor/name_filter.rb,
lib/brandish/processor/pair_filter.rb

Overview

Processors for Brandish. These just handle reshaping nodes so that they output nicely. This can be used for things like including, bold tags, etc.

Defined Under Namespace

Modules: Block, Command, NameFilter, PairFilter Classes: Base, Context, Descend, Inline

Class Method Summary collapse

Class Method Details

.all{(::Symbol, ::Symbol) => Processor::Base}

A structure containing all of the processors available. This is a key value store, with the key being the format and the name, and the value being the actual processor.

Returns:



22
23
24
# File 'lib/brandish/processor.rb', line 22

def self.all
  @_processors ||= ::Hash.new
end

.register(map) ⇒ void

This method returns an undefined value.

Registers processors with the global registry. This interns the format and name of the processor. If the format and name pair already exists, it raises a Brandish::ProcessorError.

Examples:

Processor.register [:html, :stripper] => self
Processor.register [:all, :descend] => self

Parameters:

  • map ({(::Symbol, ::Symbol) => Processor::Base})

    The processors to register.

Raises:

  • (ProcessorError)

    If one of the format and name pairs already exists.



39
40
41
42
43
44
45
46
# File 'lib/brandish/processor.rb', line 39

def self.register(map)
  map.each do |(format, name), processor|
    format, name = format.intern, name.intern
    fail ProcessorError, "#{format}:#{name} already exists" \
      if all.key?([format, name])
    all[[format, name]] = processor
  end
end