class BinData::Virtual
:value
] The virtual object will always have this value.
of this evaluated parameter is false.
[:assert
] Raise an error when reading or assigning if the value
an object. These params include those for BinData::Base as well as:
Parameters may be provided at initialisation to control the behaviour of
== Parameters
obj = A.read(“abcdeABCDE”) #=> BinData::ValidityError: assertion failed for obj.c
obj.c.rel_offset #=> 10
obj.a #=> “abcde”
obj = A.read(“abcdeabcde”)
end
virtual :c, assert: -> { a == b }
string :b, read_length: 5
string :a, read_length: 5
class A < BinData::Record
require ‘bindata’
for determining offsets or storing values.
the data stream. It is used to make assertions or as a convenient label
A virtual field is one that is neither read, written nor occupies space in
def do_num_bytes
def do_num_bytes 0.0 end
def do_read(io); end
def do_read(io); end
def do_write(io); end
def do_write(io); end
def sensible_default
def sensible_default nil end