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.offset #=> 10
obj.a #=> “abcde”
obj = A.read(“abcdeabcde”)
end
virtual :c, :assert => lambda { 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 read_and_return_value(io)
def read_and_return_value(io) nil end
def sensible_default
def sensible_default nil end
def value_to_binary_string(val)
def value_to_binary_string(val) "" end