Class: Stream::MappedStream

### Home Classes Methods

### In Files

- lib/stream.rb

### Parent

Stream::WrappedStream

### Methods

- ::new
- #basic_backward
- #basic_forward

### Class/Module Index

Quicksearch

- Stream
- Stream::BasicStream
- Stream::CollectionStream
- Stream::ConcatenatedStream
- Stream::EmptyStream
- Stream::EndOfStreamException
- Stream::FilteredStream
- Stream::ImplicitStream
- Stream::IntervalStream
- Stream::MappedStream
- Stream::ReversedStream
- Stream::WrappedStream
- Array
- Enumerable
- Generator
- Object

No matching classes.

# Stream::MappedStream

The analog to Enumerable#collect for a stream is a MappedStream wrapping another stream. A MappedStream is created by the method collect, thus modifying the behavior mixed in by Enumerable:

    (1..5).create_stream.collect {|x| x**2}.type ==> Stream::MappedStream
    (1..5).collect {|x| x**2} ==> [1, 4, 9, 16, 25]
    (1..5).create_stream.collect {|x| x**2}.to_a ==> [1, 4, 9, 16, 25]

### Public Class Methods

new(otherStream, &mapping) click to toggle source

Creates a new MappedStream wrapping otherStream which calls the block mapping on each move.

    # File lib/stream.rb, line 345
    def initialize (otherStream, &mapping)
      super otherStream
      @mapping = mapping
    end

### Public Instance Methods

basic_backward() click to toggle source

Apply the stored closure for the previous element in the wrapped stream and return the result.

    # File lib/stream.rb, line 355
    def basic_backward; @mapping.call(super); end

basic_forward() click to toggle source

Apply the stored closure for the next element in the wrapped stream and return the result.

    # File lib/stream.rb, line 352
    def basic_forward; @mapping.call(super); end

[Validate]

Generated with the Darkfish Rdoc Generator 2.