Class: IOStreams::Bzip2::Writer

Inherits:
Writer
  • Object
show all
Defined in:
lib/io_streams/bzip2/writer.rb

Instance Attribute Summary

Attributes inherited from Writer

#output_stream

Class Method Summary collapse

Methods inherited from Writer

file, #initialize, open

Constructor Details

This class inherits a constructor from IOStreams::Writer

Class Method Details

.stream(input_stream, original_file_name: nil, **_args) ⇒ Object

Write to a stream, compressing with Bzip2



5
6
7
8
9
10
11
12
13
14
# File 'lib/io_streams/bzip2/writer.rb', line 5

def self.stream(input_stream, original_file_name: nil, **_args)
  Utils.load_soft_dependency('rbzip2', 'Bzip2') unless defined?(RBzip2)

  begin
    io = RBzip2.default_adapter::Compressor.new(input_stream)
    yield io
  ensure
    io&.close
  end
end