class RemiLib::Compression::BZip2::Writer

Overview

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 an instance.

Example of a simple compressor:

# Compress `file` and save to `output`.
File.open(bzip2file, "rb") do |file|
  File.open(outputfile, "wb") do |output|
    RemiLib::Compression::BZip2::Writer.open(output) do |bzio|
      IO.copy(bzio, output)
    end
  end
end

Defined in:

remilib/compression/bzip/writer.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class IO

endBold : self endBold, endColor : self endColor, endConceal : self endConceal, endCrossedOut : self endCrossedOut, endEncircled : self endEncircled, endFaint : self endFaint, endFastBlink : self endFastBlink, endFraktur : self endFraktur, endFramed : self endFramed, endItalic : self endItalic, endOverlined : self endOverlined, endReverseVideo : self endReverseVideo, endSlowBlink : self endSlowBlink, endUnderline : self endUnderline, readBytes(count : Int) : Bytes readBytes, readFloat32 readFloat32, readFloat32BE readFloat32BE, readFloat64 readFloat64, readFloat64BE readFloat64BE, readInt128 readInt128, readInt128BE readInt128BE, readInt16 readInt16, readInt16BE readInt16BE, readInt24 readInt24, readInt24BE readInt24BE, readInt32 readInt32, readInt32BE readInt32BE, readInt64 readInt64, readInt64BE readInt64BE, readInt8 readInt8, readUInt128 readUInt128, readUInt128BE readUInt128BE, readUInt16 readUInt16, readUInt16BE readUInt16BE, readUInt32 readUInt32, readUInt32BE readUInt32BE, readUInt64 readUInt64, readUInt64BE readUInt64BE, readUInt8 readUInt8, startBold : self startBold, startColor(fg : RemiLib::Console::Color, bg : RemiLib::Console::Color = RemiLib::Console::Color::Default) : self startColor, startConceal : self startConceal, startCrossedOut : self startCrossedOut, startEncircled : self startEncircled, startFaint : self startFaint, startFastBlink : self startFastBlink, startFraktur : self startFraktur, startFramed : self startFramed, startItalic : self startItalic, startOverlined : self startOverlined, startReverseVideo : self startReverseVideo, startSlowBlink : self startSlowBlink, startUnderline : self startUnderline, withBold(&) withBold, withColor(fg : RemiLib::Console::Color, bg : RemiLib::Console::Color = RemiLib::Console::Color::Default, &) : self withColor, withConceal(&) withConceal, withCrossedOut(&) withCrossedOut, withEncircled(&) withEncircled, withExcursion(gotoHere, &)
withExcursion(&)
withExcursion
, withFaint(&) withFaint, withFastBlink(&) withFastBlink, withFraktur(&) withFraktur, withFramed(&) withFramed, withItalic(&) withItalic, withOverlined(&) withOverlined, withReverseVideo(&) withReverseVideo, withSlowBlink(&) withSlowBlink, withUnderline(&) withUnderline, writeFloat32(value : Float32) : self writeFloat32, writeFloat32BE(value : Float32) : self writeFloat32BE, writeFloat64(value : Float64) : self writeFloat64, writeFloat64BE(value : Float64) : self writeFloat64BE, writeInt128(value : Int128) : self writeInt128, writeInt128BE(value : Int128) : self writeInt128BE, writeInt16(value : Int16) : self writeInt16, writeInt16BE(value : Int16) : self writeInt16BE, writeInt24(data : Int32) writeInt24, writeInt24BE(data : Int32) writeInt24BE, writeInt32(value : Int32) : self writeInt32, writeInt32BE(value : Int32) : self writeInt32BE, writeInt64(value : Int64) : self writeInt64, writeInt64BE(value : Int64) : self writeInt64BE, writeInt8(value : Int8) : Nil writeInt8, writeUInt128(value : UInt128) : self writeUInt128, writeUInt128BE(value : UInt128) : self writeUInt128BE, writeUInt16(value : UInt16) : self writeUInt16, writeUInt16BE(value : UInt16) : self writeUInt16BE, writeUInt32(value : UInt32) : self writeUInt32, writeUInt32BE(value : UInt32) : self writeUInt32BE, writeUInt64(value : UInt64) : self writeUInt64, writeUInt64BE(value : UInt64) : self writeUInt64BE, writeUInt8(value : UInt8) : Nil writeUInt8

Class methods inherited from class IO

readBytes(io : IO, count : Int) : Bytes readBytes, readFloat32(io : IO) : Float32 readFloat32, readFloat32BE(io : IO) : Float32 readFloat32BE, readFloat64(io : IO) : Float64 readFloat64, readFloat64BE(io : IO) : Float64 readFloat64BE, readInt128(io : IO) : Int128 readInt128, readInt128BE(io : IO) : Int128 readInt128BE, readInt16(io : IO) : Int16 readInt16, readInt16BE(io : IO) : Int16 readInt16BE, readInt24(io : IO) : Int32 readInt24, readInt24BE(io : IO) : Int32 readInt24BE, readInt32(io : IO) : Int32 readInt32, readInt32BE(io : IO) : Int32 readInt32BE, readInt64(io : IO) : Int64 readInt64, readInt64BE(io : IO) : Int64 readInt64BE, readInt8(io : IO) : Int8 readInt8, readUInt128(io : IO) : UInt128 readUInt128, readUInt128BE(io : IO) : UInt128 readUInt128BE, readUInt16(io : IO) : UInt16 readUInt16, readUInt16BE(io : IO) : UInt16 readUInt16BE, readUInt32(io : IO) : UInt32 readUInt32, readUInt32BE(io : IO) : UInt32 readUInt32BE, readUInt64(io : IO) : UInt64 readUInt64, readUInt64BE(io : IO) : UInt64 readUInt64BE, readUInt8(io : IO) : UInt8 readUInt8, writeInt8(io : IO, value : Int8) : Nil writeInt8, writeUInt8(io : IO, value : UInt8) : Nil writeUInt8

Constructor Detail

def self.new(output : IO, level : Int32 = DEFAULT_COMPRESSION_LEVEL, sync_close : Bool = false) #

Creates an instance of Writer. #close must be invoked after all data has written. level will be clamped to MIN_COMPRESSION_LEVEL and MAX_COMPRESSION_LEVEL if it is outside those values.


[View source]

Class Method Detail

def self.open(io : IO, level : Int32 = DEFAULT_COMPRESSION_LEVEL, sync_close : Bool = false, &) #

Creates a new writer for the given io, yields it to the given block, then closes it at its end.


[View source]

Instance Method Detail

def close : Nil #

Closes this writer. Must be invoked after all data has been written.


[View source]
def closed? : Bool #

Returns true if this IO is closed.


[View source]
def flush : Nil #

Not implemented for a BZip2 Writer, always raises an exception.


[View source]
def inspect(io : IO) : Nil #
Description copied from class Reference

Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>

[View source]
def read(slice : Bytes) : NoReturn #

Always raises IO::Error because this is a write-only IO.


[View source]
def sync_close=(sync_close : Bool) #

If #sync_close? is true, closing this IO will close the underlying IO.


[View source]
def sync_close? : Bool #

If #sync_close? is true, closing this IO will close the underlying IO.


[View source]
def write(slice : Bytes) : Nil #

See IO#write.


[View source]