Class: Zip::Bzip2::Decompressor

Inherits:
Decompressor
  • Object
show all
Defined in:
lib/zip/bzip2/decompressor.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Decompressor

Returns a new instance of Decompressor.



8
9
10
11
12
13
# File 'lib/zip/bzip2/decompressor.rb', line 8

def initialize(*args)
  super

  @buffer = +''
  @bzip2_ffi_decompressor = ::Zip::Bzip2::Decompress.new
end

Instance Method Details

#eofObject Also known as: eof?



23
24
25
# File 'lib/zip/bzip2/decompressor.rb', line 23

def eof
  @buffer.empty? && input_finished?
end

#read(length = nil, outbuf = +'')) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/zip/bzip2/decompressor.rb', line 15

def read(length = nil, outbuf = +'')
  return return_value_on_eof(length) if eof

  fill_buffer(length)

  outbuf.replace(@buffer.slice!(0...(length || @buffer.bytesize)))
end