Compress::BZ2::Writer
A write-only IO object to compress data in the bzip2 format.
Instances of this class wrap another IO object. When you write to this
instance, it compresses the data and writes it to the underlying IO.
NOTE: unless created with a block, close must be invoked after all
data has been written to a BZ2::Writer instance.
Example: compress a file
require "bz2"
File.open("./file.txt", "r") do |input_file|
File.open("./file.bz2", "w") do |output_file|
Compress::BZ2::Writer.open(output_file) do |bz2|
IO.copy(input_file, bz2)
end
end
end
Constructors
Creates an instance of BZ2::Writer. close must be invoked after all
data has been written.
block_size100k controls the compressor's block size in units of 100kB (1..9, default 9 - the highest compression). work_factor (0..250, default 0 meaning bzlib's own default of 30) only affects how the compressor behaves on highly repetitive data - it never affects the decompressor.
Class methods
Creates a new writer to the given io, yields it to the given block, and closes it at the end.