IOWindow represents an IO object which wraps another one allowing read and/or write access to a subset of the data within the stream.
NOTE: This object is NOT thread safe.
Creates a new instance of this class using io as the data source and where window_position and window_size define the location and size of data window respectively.
io must be opened for reading and must be seekable. window_position must be an integer greater than or equal to 0. window_size must be an integer greater than or equal to 0.
# File lib/archive/support/iowindow.rb, line 18 def initialize(io, window_position, window_size) @io = io @unbuffered_pos = 0 self.window_position = window_position self.window_size = window_size end
Set the file position at which this window begins. window_position must be an integer greater than or equal to 0.
# File lib/archive/support/iowindow.rb, line 30 def window_position=(window_position) unless window_position.respond_to?(:to_int) then raise TypeError, "can't convert #{window_position.class} into Integer" end window_position = window_position.to_int if window_position < 0 then raise ArgumentError, 'non-positive window position given' end @window_position = window_position end
Set the size of the window. window_size must be an integer greater than or equal to 0.
# File lib/archive/support/iowindow.rb, line 47 def window_size=(window_size) unless window_size.respond_to?(:to_int) then raise TypeError, "can't convert #{window_size.class} into Integer" end window_size = window_size.to_int raise ArgumentError, 'non-positive window size given' if window_size < 0 @window_size = window_size end
Generated with the Darkfish Rdoc Generator 2.