Class: Fabulator::Expr::ForExpr
- Inherits:
-
Object
- Object
- Fabulator::Expr::ForExpr
- Defined in:
- lib/fabulator/expr/for_expr.rb
Instance Method Summary collapse
- #expr_type(context) ⇒ Object
-
#initialize(v, e) ⇒ ForExpr
constructor
A new instance of ForExpr.
- #run(context, autovivify = false) ⇒ Object
Constructor Details
Instance Method Details
#expr_type(context) ⇒ Object
14 15 16 |
# File 'lib/fabulator/expr/for_expr.rb', line 14 def expr_type(context) @expr.expr_type(context) end |
#run(context, autovivify = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fabulator/expr/for_expr.rb', line 18 def run(context, autovivify = false) result = [ ] return result if @var.nil? || @expr.nil? count = 1 @var.each_binding(context, autovivify) do |b| b.position = count result = result + @expr.run(b) count += 1 end return result end |