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