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.
16 17 18 19 |
# File 'lib/rley/formatter/debug.rb', line 16 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.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rley/formatter/debug.rb', line 29 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
11 12 13 |
# File 'lib/rley/formatter/debug.rb', line 11 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_'
24 25 26 |
# File 'lib/rley/formatter/debug.rb', line 24 def accept_all return true end |