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
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/bindata/base_primitive.rb', line 204 def assert! current_value = snapshot expected = eval_parameter(:assert, :value => current_value) msg = if not expected and current_value.nil? "assertion failed" elsif not expected "value '#{current_value}' not as expected" elsif expected != true and current_value != expected "value is '#{current_value}' but expected '#{expected}'" else nil end raise ValidityError, "#{msg} for #{debug_name}" if msg end |
#assign(val) ⇒ Object
194 195 196 197 |
# File 'lib/bindata/base_primitive.rb', line 194 def assign(val) super(val) assert! end |
#do_read(io) ⇒ Object
:nodoc:
199 200 201 202 |
# File 'lib/bindata/base_primitive.rb', line 199 def do_read(io) #:nodoc: super(io) assert! end |