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
Source
# File lib/stream.rb 421 def initialize(other_stream) 422 super other_stream 423 set_to_begin 424 end
Create a reversing wrapper for the reversable stream other_stream. If other_stream does not support backward moving a NotImplementedError is signaled on the first backward move.
Calls superclass method
Stream::WrappedStream::new
Public Instance Methods
Source
# File lib/stream.rb 427 def at_beginning? 428 wrapped_stream.at_end? 429 end
Returns true if the wrapped stream is at_end?.
Source
# File lib/stream.rb 432 def at_end? 433 wrapped_stream.at_beginning? 434 end
Returns true if the wrapped stream is at_beginning?.
Source
# File lib/stream.rb 442 def basic_backward 443 wrapped_stream.basic_forward 444 end
Moves the wrapped stream one step forward.
Source
# File lib/stream.rb 437 def basic_forward 438 wrapped_stream.basic_backward 439 end
Moves the wrapped stream one step backward.
Source
# File lib/stream.rb 452 def set_to_begin 453 wrapped_stream.set_to_end 454 end
Sets the wrapped stream to the end.
Source
# File lib/stream.rb 447 def set_to_end 448 wrapped_stream.set_to_begin 449 end
Sets the wrapped stream to the beginning.