class

Compress::LZ4::Reader

Inherits IO / Reference / Object

string = File.open("file.lz4") do |file| Compress::LZ4::Reader.open(file) do |lz4| lz4.gets_to_end end end pp string

Constructors

new(io : IO, sync_close : Bool = false)
Source
new(filename : String)

Creates a new reader from the given filename.

Source

Class methods

open(io : IO, sync_close : Bool = false, &)

Creates a new reader from the given io, yields it to the given block, and closes it at its end.

Source
open(io : IO, sync_close = false, &)

Creates a new reader from the given io, yields it to the given block, and closes it at the end.

Source
open(filename : String, &)

Creates a new reader from the given filename, yields it to the given block, and closes it at the end.

Source

Instance methods

close

Closes this IO.

IO defines this is a no-op method, but including types may override.

Source
closed?

Returns true if this IO is closed.

IO defines returns false, but including types may override.

Source
compressed_bytes
Source
compression_ratio

Uncompressed bytes outputted / compressed bytes read so far in the stream

Source
finalize
Source
flush

Flushes buffered data, if any.

IO defines this is a no-op method, but including types may override.

Source
read(slice : Bytes) : Int32

Reads at most slice.size bytes from this IO into slice. Returns the number of bytes read, which is 0 if and only if there is no more data to read (so checking for 0 is the way to detect end of file).

io = IO::Memory.new "hello"
slice = Bytes.new(4)
io.read(slice) # => 4
slice          # => Bytes[104, 101, 108, 108]
io.read(slice) # => 1
slice          # => Bytes[111, 101, 108, 108]
io.read(slice) # => 0
Source
rewind

Rewinds this IO. By default this method raises, but including types may implement it.

Source
sync_close=(sync_close : Bool)
Source
sync_close?
Source
uncompressed_bytes
Source
write(slice : Bytes) : Nil

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

Source