Class: Omnizip::Algorithms::LZMA::LzipDecoder::TrackingInputStream

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/algorithms/lzma/lzip_decoder.rb

Overview

Wrapper input stream that tracks bytes read

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, start_offset = 0) ⇒ TrackingInputStream

Returns a new instance of TrackingInputStream.



344
345
346
347
# File 'lib/omnizip/algorithms/lzma/lzip_decoder.rb', line 344

def initialize(input, start_offset = 0)
  @input = input
  @bytes_read = start_offset
end

Instance Attribute Details

#bytes_readObject (readonly)

Returns the value of attribute bytes_read.



342
343
344
# File 'lib/omnizip/algorithms/lzma/lzip_decoder.rb', line 342

def bytes_read
  @bytes_read
end

Instance Method Details

#eof?Boolean

Returns:

  • (Boolean)


361
362
363
# File 'lib/omnizip/algorithms/lzma/lzip_decoder.rb', line 361

def eof?
  @input.eof?
end

#getbyteObject



355
356
357
358
359
# File 'lib/omnizip/algorithms/lzma/lzip_decoder.rb', line 355

def getbyte
  byte = @input.getbyte
  @bytes_read += 1 if byte
  byte
end

#read(size = nil) ⇒ Object



349
350
351
352
353
# File 'lib/omnizip/algorithms/lzma/lzip_decoder.rb', line 349

def read(size = nil)
  data = @input.read(size)
  @bytes_read += data.bytesize if data
  data
end