Class: Rley::Formatter::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rley/formatter/base_formatter.rb

Overview

Superclass for parse tree formatters.

Direct Known Subclasses

Asciitree, BracketNotation, Debug, Json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(anIO) ⇒ BaseFormatter

Constructor. be placed.

Parameters:

  • anIO (IO)

    an output IO where the formatter's result will



15
16
17
# File 'lib/rley/formatter/base_formatter.rb', line 15

def initialize(anIO)
  @output = anIO
end

Instance Attribute Details

#outputIO (readonly)

The IO output stream in which the formatter's result will be sent.

Returns:

  • (IO)

    The output stream for the formatter.



10
11
12
# File 'lib/rley/formatter/base_formatter.rb', line 10

def output
  @output
end

Instance Method Details

#render(aVisitor) ⇒ Object

Given a parse tree visitor, perform the visit and render the visit events in the output stream.

Parameters:



22
23
24
25
26
# File 'lib/rley/formatter/base_formatter.rb', line 22

def render(aVisitor)
  aVisitor.subscribe(self)
  aVisitor.start
  aVisitor.unsubscribe(self)
end