Class: TreeStand::AstModifier
- Inherits:
-
Object
- Object
- TreeStand::AstModifier
- Defined in:
- lib/tree_stand/ast_modifier.rb
Overview
An experimental class to modify the AST. I re-runs the query on the modified document every loop to ensure that the match is still valid.
Instance Method Summary collapse
-
#initialize(tree) ⇒ AstModifier
constructor
A new instance of AstModifier.
- #on_match(query) {|self, match| ... } ⇒ void
Constructor Details
#initialize(tree) ⇒ AstModifier
Returns a new instance of AstModifier.
8 9 10 |
# File 'lib/tree_stand/ast_modifier.rb', line 8 def initialize(tree) @tree = tree end |
Instance Method Details
#on_match(query) {|self, match| ... } ⇒ void
This method returns an undefined value.
16 17 18 19 20 21 22 23 |
# File 'lib/tree_stand/ast_modifier.rb', line 16 def on_match(query) matches = @tree.query(query) while !matches.empty? yield self, matches.first matches = @tree.query(query) end end |