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

Returns a new instance of WhileLoopWrapper.



745
746
747
748
# File 'lib/eggshell/bundles/basics.rb', line 745

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

Instance Method Details

#each(&block) ⇒ Object



750
751
752
753
754
755
756
757
758
759
760
# File 'lib/eggshell/bundles/basics.rb', line 750

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