Class: Sequitur::Formatter::BaseFormatter
- Inherits:
-
Object
- Object
- Sequitur::Formatter::BaseFormatter
- Defined in:
- lib/sequitur/formatter/base_formatter.rb
Overview
Superclass for grammar formatters.
Instance Attribute Summary collapse
-
#output ⇒ Object
The IO output stream in which the formatter's result will be sent.
Instance Method Summary collapse
-
#initialize(anIO) ⇒ BaseFormatter
constructor
Constructor.
-
#render(aGrmOrVisitor) ⇒ Object
Given a grammar or a grammar visitor, perform the visit and render the visit events in the output stream.
Constructor Details
#initialize(anIO) ⇒ BaseFormatter
Constructor. be placed.
14 15 16 |
# File 'lib/sequitur/formatter/base_formatter.rb', line 14 def initialize(anIO) @output = anIO end |
Instance Attribute Details
#output ⇒ Object
The IO output stream in which the formatter's result will be sent.
9 10 11 |
# File 'lib/sequitur/formatter/base_formatter.rb', line 9 def output @output end |
Instance Method Details
#render(aGrmOrVisitor) ⇒ Object
Given a grammar or a grammar visitor, perform the visit and render the visit events in the output stream.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sequitur/formatter/base_formatter.rb', line 21 def render(aGrmOrVisitor) a_visitor = if aGrmOrVisitor.kind_of?(GrammarVisitor) aGrmOrVisitor else aGrmOrVisitor.visitor end a_visitor.subscribe(self) a_visitor.start a_visitor.unsubscribe(self) end |