Class: BinData::Transform::LZ4
Overview
Transforms a LZ4 compressed data stream.
gem install extlz4
Instance Method Summary
collapse
#before_transform, #num_bytes_remaining, #offset, #prepend_to_chain, #seek_abs, #seekable?, #skip, transform_changes_stream_length!
Constructor Details
#initialize(read_length) ⇒ LZ4
Returns a new instance of LZ4.
11
12
13
14
|
# File 'lib/bindata/transform/lz4.rb', line 11
def initialize(read_length)
super()
@length = read_length
end
|
Instance Method Details
26
27
28
|
# File 'lib/bindata/transform/lz4.rb', line 26
def after_read_transform
raise IOError, "didn't read all data" unless @read.empty?
end
|
30
31
32
|
# File 'lib/bindata/transform/lz4.rb', line 30
def after_write_transform
chain_write(::LZ4::encode(@write))
end
|
#read(n) ⇒ Object
16
17
18
19
|
# File 'lib/bindata/transform/lz4.rb', line 16
def read(n)
@read ||= ::LZ4::decode(chain_read(@length))
@read.slice!(0...n)
end
|
#write(data) ⇒ Object
21
22
23
24
|
# File 'lib/bindata/transform/lz4.rb', line 21
def write(data)
@write ||= create_empty_binary_string
@write << data
end
|