Class: IOWindow

Inherits:
Object
  • Object
show all
Includes:
IO::Like
Defined in:
lib/archive/support/iowindow.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, window_position, window_size) ⇒ IOWindow

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.


19
20
21
22
23
24
# File 'lib/archive/support/iowindow.rb', line 19

def initialize(io, window_position, window_size)
  @io = io
  @unbuffered_pos = 0
  self.window_position = window_position
  self.window_size = window_size
end

Instance Attribute Details

#window_positionObject

The file position at which this window begins.


27
28
29
# File 'lib/archive/support/iowindow.rb', line 27

def window_position
  @window_position
end

#window_sizeObject

The size of the window.


44
45
46
# File 'lib/archive/support/iowindow.rb', line 44

def window_size
  @window_size
end