This project is closed and read-only.
Bug #852 ยป generator.rb.diff
| lib/generator.rb (working copy) | ||
|---|---|---|
|
# In the latter, the given block is called with the generator
|
||
|
# itself, and expected to call the +yield+ method for each element.
|
||
|
def initialize(enum = nil, &block)
|
||
|
if enum
|
||
|
if @enum = enum
|
||
|
@block = proc { |g|
|
||
|
enum.each { |x| g.yield x }
|
||
|
}
|
||
| ... | ... | |
|
# Rewinds the generator.
|
||
|
def rewind()
|
||
|
if @enum && @enum.respond_to?(:rewind)
|
||
|
@enum.rewind
|
||
|
end
|
||
|
initialize(nil, &@block) if @index.nonzero?
|
||
|
self
|
||