Class: Enumerator::Yielder

### Home Classes Methods

### In Files

- lib/backports/1.9.1/enumerator/new.rb
- lib/backports/2.0.0/enumerable/lazy.rb

### Parent

Object

### Methods

- ::new
- #<<
- #yield

### Class/Module Index

Quicksearch

- Prime
- Prime::EratosthenesGenerator
- Prime::EratosthenesSieve
- Prime::Generator23
- Prime::OldCompatibility
- Prime::PseudoPrimeGenerator
- Prime::TrialDivision
- Prime::TrialDivisionGenerator
- Backports
- Backports::MOST_EXTREME_OBJECT_EVER
- Backports::Random
- Backports::Random::Implementation
- Backports::Random::MT19937
- Backports::StdLib
- Backports::StdLib::LoadedFeatures
- Enumerator
- Enumerator::GeneratorBP
- Enumerator::Lazy
- Enumerator::Yielder
- Matrix
- Matrix::EigenvalueDecomposition
- Matrix::LUPDecomposition
- Enumerable
- Enumerable::Enumerator
- File
- File::Constants
- ARGF
- Array
- BasicObject
- Bignum
- Binding
- Complex
- Dir
- ENV
- Fixnum
- Float
- GC
- Hash
- IO
- Integer
- Kernel
- Math
- Method
- Module
- NilClass
- Numeric
- Object
- ObjectSpace
- OpenStruct
- Proc
- Process
- Random
- Range
- Regexp
- Set
- StopIteration
- String
- Struct
- Symbol
- UnboundMethod

No matching classes.

# Enumerator::Yielder

A simple class which allows the construction of Enumerator from a block

### Attributes

backports_memo[RW]

Current API for Lazy Enumerator does not provide an easy way to handle internal state. We "cheat" and use yielder to hold it for us. A new yielder is created when generating or after a `rewind`. This way we avoid issues like bugs.ruby-lang.org/issues/7691 or bugs.ruby-lang.org/issues/7696

### Public Class Methods

new(&block) click to toggle source

    # File lib/backports/1.9.1/enumerator/new.rb, line 10
    def initialize(&block)
      @final_block = block
    end

### Public Instance Methods

<<(*arg) click to toggle source

    # File lib/backports/1.9.1/enumerator/new.rb, line 18
    def <<(*arg)
      @final_block.call(*arg)
      self
    end

yield(*arg) click to toggle source

    # File lib/backports/1.9.1/enumerator/new.rb, line 14
    def yield(*arg)
      @final_block.call(*arg)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.