class Stream::ReversedStream
Each reversable stream (a stream that implements backward and at_beginning?) can be wrapped by a ReversedStream.
A ReversedStream is created by the method reverse:
(1..6).create_stream.reverse.to_a ==> [6, 5, 4, 3, 2, 1]
Public Class Methods
new(otherStream)
click to toggle source
Create a reversing wrapper for the reversable stream otherStream. If otherStream does not support backward moving a NotImplementedError is signaled on the first backward move.
Calls superclass method
Stream::WrappedStream.new
# File lib/stream.rb, line 311 def initialize (otherStream) super otherStream set_to_begin end
Public Instance Methods
at_beginning?()
click to toggle source
Returns true if the wrapped stream is at_end?.
# File lib/stream.rb, line 317 def at_beginning?; wrapped_stream.at_end?; end
at_end?()
click to toggle source
Returns true if the wrapped stream is at_beginning?.
# File lib/stream.rb, line 319 def at_end?; wrapped_stream.at_beginning?; end
basic_backward()
click to toggle source
Moves the wrapped stream one step forward.
# File lib/stream.rb, line 324 def basic_backward; wrapped_stream.basic_forward; end
basic_forward()
click to toggle source
Moves the wrapped stream one step backward.
# File lib/stream.rb, line 322 def basic_forward; wrapped_stream.basic_backward; end
set_to_begin()
click to toggle source
Sets the wrapped stream to the end.
# File lib/stream.rb, line 329 def set_to_begin; wrapped_stream.set_to_end; end
set_to_end()
click to toggle source
Sets the wrapped stream to the beginning.
# File lib/stream.rb, line 327 def set_to_end; wrapped_stream.set_to_begin; end