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



12
13
14
# File 'lib/rley/formatter/base_formatter.rb', line 12

def initialize(anIO)
  @output = anIO
end

Instance Attribute Details

#outputObject (readonly)

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



7
8
9
# File 'lib/rley/formatter/base_formatter.rb', line 7

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:



19
20
21
22
23
# File 'lib/rley/formatter/base_formatter.rb', line 19

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