Class: Eggshell::Bundles::Basic::ControlLoopMacros::WhileLoopWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/eggshell/bundles/basics.rb

Instance Method Summary collapse

Constructor Details

#initialize(eggshell, cond) ⇒ WhileLoopWrapper



782
783
784
785
# File 'lib/eggshell/bundles/basics.rb', line 782

def initialize(eggshell, cond)
  @eggshell = eggshell
  @cond = cond
end

Instance Method Details

#each(&block) ⇒ Object



787
788
789
790
791
792
793
794
795
796
797
# File 'lib/eggshell/bundles/basics.rb', line 787

def each(&block)
  counter = 0
  struct = Eggshell::ExpressionEvaluator.struct(@cond)

  cond = @eggshell.expr_eval(struct)
  while cond
    yield(counter)
    counter += 1
    cond = @eggshell.expr_eval(struct)
  end
end