### Home Classes Methods

### In Files

- lib/facets/enumerator.rb
- lib/facets/enumerator/fx.rb

### Parent

Object

### Methods

- ::new
- #fx
- #fx_send
- #old_initialize

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Lazy
- Lazy::Future
- Lazy::Promise
- Lazy::Promise::DIVERGES
- Lazy::PromiseSafe
- Enumerable
- Enumerable::Recursor
- Method
- Method::Composition
- Module
- Module::InstanceFunction
- Array
- Binding
- Class
- Comparable
- Denumerable
- Denumerator
- Dir
- Enumerator
- Exception
- Facets
- FalseClass
- File
- FileTest
- Fixnum
- Float
- Functor
- Hash
- Indexable
- Instance
- Integer
- Kernel
- MatchData
- NA
- NilClass
- Numeric
- Object
- ObjectSpace
- Proc
- Process
- Range
- Regexp
- String
- Struct
- Symbol
- Time
- TrueClass
- UnboundMethod

No matching classes.

# Enumerator

### Public Class Methods

new(*args, &block) click to toggle source

Provides the ruby-1.9 block form of Enumerator, where you can write:

    obj = Enumerator.new do |yielder|
      # ...
      yielder.yield(data)  # or: yielder << data
      # ...
    end

When obj.each is called, the block is run once. It should call yielder.yield with each item it wishes to generate.

Example:

    fib = Enumerator.new { |y|
      a = b = 1
      loop {
        y << a
        a, b = b, a + b
      }
    }

    fib.take(10)  #=> [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

    # File lib/facets/enumerator.rb, line 37
    def initialize(*args, &block)
      if block
        @body = block
        old_initialize(self, :_start)
      else
        old_initialize(*args)
      end
    end

Also aliased as: old_initialize

### Public Instance Methods

fx() click to toggle source

    # File lib/facets/enumerator/fx.rb, line 15
    def fx
      Functor.new(&method(:fx_send).to_proc)
    end

### Private Instance Methods

fx_send(op, *a, &b) click to toggle source

    # File lib/facets/enumerator/fx.rb, line 22
    def fx_send(op, *a, &b)
      map{ |e| e.send(op, *a, &b) }
    end

old_initialize(*args, &block) click to toggle source
Alias for: new

[Validate]

Generated with the Darkfish Rdoc Generator 2.