Module: BinData::BasePrimitive::AssertPlugin
- Defined in:
- lib/bindata/base_primitive.rb
Overview
Logic for the :assert parameter
Instance Method Summary collapse
Instance Method Details
#assert! ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/bindata/base_primitive.rb', line 201 def assert! current_value = snapshot expected = eval_parameter(:assert, :value => current_value) if not expected raise ValidityError, "value '#{current_value}' not as expected for #{debug_name}" elsif current_value != expected and expected != true raise ValidityError, "value is '#{current_value}' but " + "expected '#{expected}' for #{debug_name}" end end |
#assign(val) ⇒ Object
191 192 193 194 |
# File 'lib/bindata/base_primitive.rb', line 191 def assign(val) super(val) assert! end |
#do_read(io) ⇒ Object
:nodoc:
196 197 198 199 |
# File 'lib/bindata/base_primitive.rb', line 196 def do_read(io) #:nodoc: super(io) assert! end |