Class: LazyEnumerator

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/coroutines.rb

Defined Under Namespace

Classes: Yielder

Instance Method Summary collapse

Methods included from Enumerable

#>=

Constructor Details

#initialize(obj, &block) ⇒ LazyEnumerator

Returns a new instance of LazyEnumerator.



232
233
234
# File 'lib/coroutines.rb', line 232

def initialize(obj, &block)
	@obj = obj; @block = block
end

Instance Method Details

#each(&iter_block) ⇒ Object



246
247
248
249
250
251
# File 'lib/coroutines.rb', line 246

def each(&iter_block)
	yielder = Yielder.new(iter_block)
	@obj.each do |*args|
		@block.call(yielder, *args)
	end
end