Module: Denumerable

Module | Denumerable
In: | lib/core/facets/denumerable.rb

# Denumerable

Classes which include Enumerable::Filterable will get versions of map, select etc. which return a Filter, so that they work horizontally without creating intermediate arrays.

### Methods

collect find_all map reject select skip take

### Public Instance methods

collect()

Alias for map

find_all()

Alias for select

map() {|*input| ...}

[Source]

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

reject() {|*input| ...}

[Source]

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

select() {|*input| ...}

[Source]

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

skip(n)

Skip the first n items in the list

[Source]

    # File lib/core/facets/denumerable.rb, line 54
      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)

Limit to the first n items in the list

[Source]

    # File lib/core/facets/denumerable.rb, line 42
      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]