Class: LineNumberHandler
- Inherits:
-
Psych::TreeBuilder
- Object
- Psych::TreeBuilder
- LineNumberHandler
- Defined in:
- lib/strut/extensions.rb
Overview
We need to provide a handler that will add the line to the node as it is parsed. TreeBuilder is the “usual” handler, that creates the AST.
Instance Attribute Summary collapse
-
#parser ⇒ Object
The handler needs access to the parser in order to call mark.
Instance Method Summary collapse
-
#scalar(value, anchor, tag, plain, quoted, style) ⇒ Object
We are only interested in scalars, so here we override the method so that it calls mark and adds the line info to the node.
- #start_mapping(anchor, tag, implicit, style) ⇒ Object
- #start_sequence(anchor, tag, implicit, style) ⇒ Object
Instance Attribute Details
#parser ⇒ Object
The handler needs access to the parser in order to call mark
30 31 32 |
# File 'lib/strut/extensions.rb', line 30 def parser @parser end |
Instance Method Details
#scalar(value, anchor, tag, plain, quoted, style) ⇒ Object
We are only interested in scalars, so here we override the method so that it calls mark and adds the line info to the node.
35 36 37 38 39 40 |
# File 'lib/strut/extensions.rb', line 35 def scalar value, anchor, tag, plain, quoted, style mark = parser.mark s = super s.line = mark.line s end |
#start_mapping(anchor, tag, implicit, style) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/strut/extensions.rb', line 42 def start_mapping anchor, tag, implicit, style mark = parser.mark s = super s.line = mark.line s end |
#start_sequence(anchor, tag, implicit, style) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/strut/extensions.rb', line 49 def start_sequence anchor, tag, implicit, style mark = parser.mark s = super s.line = mark.line s end |