Class: BinData::Transform::Zstd
Overview
Transforms a zstd compressed data stream.
gem install zstd-ruby
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) ⇒ Zstd
Returns a new instance of Zstd.
11
12
13
14
|
# File 'lib/bindata/transform/zstd.rb', line 11
def initialize(read_length)
super()
@length = read_length
end
|
Instance Method Details
26
27
28
|
# File 'lib/bindata/transform/zstd.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/zstd.rb', line 30
def after_write_transform
chain_write(::Zstd::compress(@write))
end
|
#read(n) ⇒ Object
16
17
18
19
|
# File 'lib/bindata/transform/zstd.rb', line 16
def read(n)
@read ||= ::Zstd::decompress(chain_read(@length))
@read.slice!(0...n)
end
|
#write(data) ⇒ Object
21
22
23
24
|
# File 'lib/bindata/transform/zstd.rb', line 21
def write(data)
@write ||= create_empty_binary_string
@write << data
end
|