Method: Heist::Runtime::Macro::Matches#expand!
- Defined in:
- lib/runtime/callable/macro/matches.rb
#expand!(template, depth) ⇒ Object
Takes a template
Expression
, a repetition depth
and a block, and calls the block n
times, where n
is the number of matches for the pattern variables in the template at the given depth and the current iteration point in the tree. After each block call, the Matches
object moves the pointer for all the applicable pattern variables along one place at the given depth – see iterate!
and Tree#shift!
.
123 124 125 126 |
# File 'lib/runtime/callable/macro/matches.rb', line 123 def (template, depth) names = Macro.pattern_vars(template) size(names, depth).times { yield() and iterate!(names, depth) } end |