Class: Iterator
Overview
Indexing
Author: Stefan Rusterholz Contact: [email protected]> Version: 1.0.0 Date: 2007-10-12
About
Similar like Enumarator, enables to create an Enumerable.
Synopsis
x = Iterator.new { |iter| [1,2,3].each { |e| iter.yield(e) } }
p x.map { |e| e*2 }
Defined Under Namespace
Classes: Iteration
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Will iterate as defined in Iterator::new.
-
#initialize(&iterator) ⇒ Iterator
constructor
Determine how to iterate, the block most contain the code that is executed to iterate.
Methods included from Enumerable
Constructor Details
#initialize(&iterator) ⇒ Iterator
Determine how to iterate, the block most contain the code that is executed to iterate.
36 37 38 |
# File 'lib/iterator.rb', line 36 def initialize(&iterator) @iterator = iterator end |