Class: Rley::Formatter::Debug
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Rley::Formatter::Debug
- Defined in:
- lib/rley/formatter/debug.rb
Overview
A formatter class that renders the visit notification events from a parse tree visitor
Instance Attribute Summary collapse
-
#indentation ⇒ Object
readonly
Current indentation level.
Attributes inherited from BaseFormatter
Instance Method Summary collapse
-
#accept_all ⇒ Boolean
Indicates that this formatter accepts all visit events provided their names start with 'before_' or 'after_'.
-
#initialize(anIO) ⇒ Debug
constructor
Constructor.
-
#method_missing(mth, *args) ⇒ Object
Ghost method pattern.
Methods inherited from BaseFormatter
Constructor Details
#initialize(anIO) ⇒ Debug
Constructor. is written.
18 19 20 21 |
# File 'lib/rley/formatter/debug.rb', line 18 def initialize(anIO) super(anIO) @indentation = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mth, *args) ⇒ Object
Ghost method pattern.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rley/formatter/debug.rb', line 31 def method_missing(mth, *args) mth_name = mth.to_s case mth_name when /^before_/ output_event(mth_name, indentation) indent unless mth_name == 'before_terminal' when /^after_/ dedent unless mth_name == 'after_terminal' output_event(mth_name, indentation) else super(mth, args) end end |
Instance Attribute Details
#indentation ⇒ Object (readonly)
Current indentation level
13 14 15 |
# File 'lib/rley/formatter/debug.rb', line 13 def indentation @indentation end |
Instance Method Details
#accept_all ⇒ Boolean
Indicates that this formatter accepts all visit events provided their names start with 'before_' or 'after_'
26 27 28 |
# File 'lib/rley/formatter/debug.rb', line 26 def accept_all return true end |