class CompositeSexpProcessor

Implements the Composite pattern on SexpProcessor. Need we say more?

Yeah… probably. Implements a SexpProcessor of SexpProcessors so you can easily chain multiple to each other. At some stage we plan on having all of them run process and but only ever output something when generate is called, allowing for deferred final processing.

Attributes

processors[R]

The list o’ processors to run.

Public Instance Methods

<<(processor) click to toggle source

Add a processor to the list of processors to run.

# File lib/composite_sexp_processor.rb, line 27
def << processor
  raise ArgumentError, "Can only add sexp processors" unless
    SexpProcessor === processor || processor.respond_to?(:process)
  @processors << processor
end
on_error_in(node_type, &block) click to toggle source
# File lib/composite_sexp_processor.rb, line 44
def on_error_in node_type, &block
  @processors.each do |processor|
    processor.on_error_in(node_type, &block)
  end
end
process(exp) click to toggle source

Run exp through all of the processors, returning the final result.

# File lib/composite_sexp_processor.rb, line 37
def process exp
  @processors.each do |processor|
    exp = processor.process(exp)
  end
  exp
end