class Stream::IntervalStream
A simple Iterator for iterating over a sequence of integers starting from zero up to a given upper bound. Mainly used by Stream::FilteredStream
. Could be made private but if somebody needs it here it is. Is there a better name for it?
The upper bound is stored in the instance variable @stop which can be incremented dynamically by the method increment_stop.
Attributes
Public Class Methods
Source
# File lib/stream.rb 255 def initialize(stop = 0) 256 @stop = stop - 1 257 set_to_begin 258 end
Create a new IntervalStream
with upper bound stop. stop - 1 is the last element. By default stop is zero which means that the stream is empty.
Public Instance Methods
Source
# File lib/stream.rb 285 def basic_backward 286 @pos -= 1 287 @pos + 1 288 end
Source
# File lib/stream.rb 277 def increment_stop(incr = 1) 278 @stop += incr 279 end
Increment the upper bound by incr.