Class: TreeStand::AstModifier
- Inherits:
-
Object
- Object
- TreeStand::AstModifier
- Extended by:
- T::Sig
- Defined in:
- lib/tree_stand/ast_modifier.rb
Overview
An experimental class to modify the AST. It re-runs the query on the modified document every loop to ensure that the match is still valid.
Instance Method Summary collapse
Constructor Details
#initialize(tree) ⇒ void
13 14 15 |
# File 'lib/tree_stand/ast_modifier.rb', line 13 def initialize(tree) @tree = tree end |
Instance Method Details
#on_match(query) {|self, match| ... } ⇒ void
This method returns an undefined value.
21 22 23 24 25 26 27 28 |
# File 'lib/tree_stand/ast_modifier.rb', line 21 def on_match(query) matches = @tree.query(query) while !matches.empty? yield self, matches.first matches = @tree.query(query) end end |