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.



739
740
741
742
# File 'lib/eggshell/bundles/basics.rb', line 739

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

Instance Method Details

#each(&block) ⇒ Object



744
745
746
747
748
749
750
751
752
753
754
# File 'lib/eggshell/bundles/basics.rb', line 744

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