class BinData::IO::Transform
::transform_changes_stream_length!
in your subclass.
data stream (e.g. compression), then call
IMPORTANT! If your transform changes the size of the underlying
and #after_write_transform
are available as well.
Additionally the hook, #before_transform
, #after_read_transform
Override the public methods #read
and #write
at a minimum.
To create a new transform layer, subclass Transform
.
Multiple transforms can be chained together.
e.g. encoding, compression, buffered.
An IO stream may be transformed before processing.
def after_read_transform; end
Flushes the input stream.
def after_read_transform; end
def after_write_transform; end
Flushes the output stream.
def after_write_transform; end
def before_transform; end
Initialises this transform.
def before_transform; end
def chain_num_bytes_remaining
def chain_num_bytes_remaining @chain_io.num_bytes_remaining end
def chain_offset
def chain_offset @chain_io.offset end
def chain_read(n)
def chain_read(n) @chain_io.read(n) end
def chain_seek_abs(n)
def chain_seek_abs(n) @chain_io.seek_abs(n) end
def chain_seekable?
def chain_seekable? @chain_io.seekable? end
def chain_skip(n)
def chain_skip(n) @chain_io.skip(n) end
def chain_write(data)
def chain_write(data) @chain_io.write(data) end
def create_empty_binary_string
def create_empty_binary_string "".force_encoding(Encoding::BINARY) end
def initialize
def initialize @chain_io = nil end
def num_bytes_remaining
def num_bytes_remaining chain_num_bytes_remaining end
def offset
def offset chain_offset end
def prepend_to_chain(chain)
Prepends this transform to the given +chain+.
def prepend_to_chain(chain) @chain_io = chain before_transform self end
def read(n)
def read(n) chain_read(n) end
def seek_abs(n)
def seek_abs(n) chain_seek_abs(n) end
def seekable?
def seekable? @chain_io.seekable? end
def skip(n)
def skip(n) chain_skip(n) end
def transform_changes_stream_length!
Indicates that this transform changes the length of the
def transform_changes_stream_length! prepend(UnSeekableIO) end
def write(data)
def write(data) chain_write(data) end