module BinData::BasePrimitive::AssertedValuePlugin

Logic for the :asserted_value parameter

Public Instance Methods

_value() click to toggle source
# File lib/bindata/base_primitive.rb, line 204
def _value
  reading? ? @value : eval_parameter(:asserted_value)
end
assert!() click to toggle source
# File lib/bindata/base_primitive.rb, line 213
def assert!
  assert_value(snapshot)
end
assert_value(current_value) click to toggle source
# File lib/bindata/base_primitive.rb, line 217
def assert_value(current_value)
  expected = eval_parameter(:asserted_value, value: current_value)
  if current_value != expected
    raise ValidityError,
          "value is '#{current_value}' but "                  "expected '#{expected}' for #{debug_name}"
  end
end
assign(val) click to toggle source
Calls superclass method
# File lib/bindata/base_primitive.rb, line 199
def assign(val)
  assert_value(val)
  super(val)
end