### Home Classes Methods

### In Files

- lib/facets/denumerable.rb

### Methods

- #collect
- #find_all
- #map
- #reject
- #select
- #skip
- #take

### 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.

# Denumerable

Classes which include Denumerable will get versions of map, select, and so on, which return a Denumerator, so that they work horizontally without creating intermediate arrays.

@author Brian Candler @author Trans

### Public Instance Methods

collect() click to toggle source
Alias for: map
find_all() click to toggle source
Alias for: select
map() click to toggle source

    # File lib/facets/denumerable.rb, line 14
    def map
      Denumerator.new do |output|
        each do |*input|
          output.yield yield(*input)
        end
      end
    end

Also aliased as: collect
reject() click to toggle source

    # File lib/facets/denumerable.rb, line 34
    def reject
      Denumerator.new do |output|
        each do |*input|
          output.yield(*input) unless yield(*input)
        end
      end
    end

select() click to toggle source

    # File lib/facets/denumerable.rb, line 24
    def select
      Denumerator.new do |output|
        each do |*input|
          output.yield(*input) if yield(*input)
        end
      end
    end

Also aliased as: find_all
skip(n) click to toggle source

Skip the first n items in the list

    # File lib/facets/denumerable.rb, line 55
    def skip(n)
      Denumerator.new do |output|
        count = 0
        each do |*input|
          output.yield(*input) if count >= n
          count += 1
        end
      end
    end

take(n) click to toggle source

Limit to the first n items in the list

    # File lib/facets/denumerable.rb, line 43
    def take(n)
      Denumerator.new do |output|
        count = 0
        each do |*input|
          break if count >= n
          output.yield(*input)
          count += 1
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.