Class Stream::MappedStream
In: lib/stream.rb
Parent: WrappedStream

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]

Methods

Public Class methods

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

Public Instance methods

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

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

[Validate]