Class: Zip::Bzip2::Decompress
- Inherits:
-
Object
- Object
- Zip::Bzip2::Decompress
- Defined in:
- lib/zip/bzip2/decompress.rb
Overview
:nodoc:
Constant Summary collapse
- OUTPUT_BUFFER_SIZE =
4096
Instance Method Summary collapse
- #decompress(data) ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(options = {}) ⇒ Decompress
constructor
A new instance of Decompress.
Constructor Details
#initialize(options = {}) ⇒ Decompress
10 11 12 13 14 15 16 17 18 |
# File 'lib/zip/bzip2/decompress.rb', line 10 def initialize( = {}) small = [:small] @libbz2 = Libbz2.new.tap do |libbz2| libbz2.decompress_init!(small: small) end @finished = false end |
Instance Method Details
#decompress(data) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zip/bzip2/decompress.rb', line 20 def decompress(data) result = +'' with_input_buffer(data) do |input_buffer| @libbz2.input_buffer = input_buffer with_output_buffer(OUTPUT_BUFFER_SIZE) do |output_buffer| while @libbz2.input? @libbz2.output_buffer = output_buffer @finished = @libbz2.decompress! result += @libbz2.output next unless @finished @libbz2.decompress_end! break end end end result end |
#finished? ⇒ Boolean
43 44 45 |
# File 'lib/zip/bzip2/decompress.rb', line 43 def finished? @finished end |