class BinData::Skip
[type_symbol, hash_params]
.
passed to it, then it should be provided as #
Symbol, or if the type is to have params #
sequence is found. The type is represented by a
a BinData::ValidityError unless an acceptable byte
This parameter contains a type that will raise:until_valid
- Skips untils a given byte pattern is matched.
:to_abs_offset
- Skips to the given absolute offset.
:length
-
The number of bytes to skip.
does, as well as the following:
Skip objects accept all the params that BinData::BasePrimitive
== Parameters
obj.b #=> “efghi”
obj = B.read(“abcdefghij”)
end
string :b, read_length: 5
skip until_valid: [:string, {read_length: 2, assert: “ef”} ]
class B < BinData::Record
obj.a #=> “fghij”
obj = A.read(“abcdefghij”)
end
string :a, read_length: 5
skip length: 5
class A < BinData::Record
require ‘bindata’
When writing, skip will write the appropriate number of zero bytes.
seekable, then the bytes are consumed and discarded.
Skip will skip over bytes from the input stream. If the stream is not
- Skips to the given absolute offset.
- Skips untils a given byte pattern is matched.
def initialize_shared_instance
def initialize_shared_instance extend SkipLengthPlugin if has_parameter?(:length) extend SkipToAbsOffsetPlugin if has_parameter?(:to_abs_offset) extend SkipUntilValidPlugin if has_parameter?(:until_valid) super end
def read_and_return_value(io)
def read_and_return_value(io) len = skip_length if len < 0 raise ValidityError, "#{debug_name} attempted to seek backwards by #{len.abs} bytes" end io.seekbytes(len) "" end
def sensible_default
def sensible_default "" end
def value_to_binary_string(val)
def value_to_binary_string(val) len = skip_length if len < 0 raise ValidityError, "#{debug_name} attempted to seek backwards by #{len.abs} bytes" end "\000" * skip_length end