class Sequence::Buffered
This class gives unidirectional sequences (i.e. IO pipes) some bidirectional capabilities. An input sequence (or input IO) and/or an output sequence (or output IO) can be specified. The #position, #position?, and #position! methods are used to control buffering. Full sequence capability (limited by the size of the buffer sequence) is accessible starting from the first #position. When the end of the buffer is reached more data is read from the input sequence (if not nil) . When no #position is outstanding, everything before the buffer sequence is written to the output sequence (if not nil). If the sequence is attempted to be moved before the buffer, the output sequence is read in reverse (which the output sequence may not like).
how much of that should remain true?
Attributes
buffer_size[RW]
pos[R]
Public Class Methods
new(input,buffer_size=1024,buffer=nil)
click to toggle source
# File lib/sequence/buffered.rb, line 22 def initialize(input,buffer_size=1024,buffer=nil) @input = input huh #@input used incorrectly... it should be used kinda like a read-once data store #and Buffered should have an independant position @buffer_size=buffer_size @buffer = buffer||@input.new_data # @output_pos = output_pos @buffer_pos=@pos=@input.pos @input.on_change_notify self end
Public Instance Methods
change_notification()
click to toggle source
# File lib/sequence/buffered.rb, line 34 def change_notification huh #invalidate (part of) @buffer if it overlaps the changed area huh #adjust @buffer_pos as necessary end