Class: Depix::Binary::Fields::U32Field
- Defined in:
- lib/depix/binary/fields.rb
Overview
unit32 field
Constant Summary collapse
- BLANK =
0xFFFFFFFF
Instance Attribute Summary
Attributes inherited from Field
Instance Method Summary collapse
- #clean(value) ⇒ Object
- #length ⇒ Object
- #pattern ⇒ Object
-
#validate!(value) ⇒ Object
Override - might be Bignum although cast to Integer sometimes.
Methods inherited from Field
#consume!, #explain, #initialize, #pack
Constructor Details
This class inherits a constructor from Depix::Binary::Fields::Field
Instance Method Details
#clean(value) ⇒ Object
76 77 78 |
# File 'lib/depix/binary/fields.rb', line 76 def clean(value) value == BLANK ? nil : value end |
#length ⇒ Object
72 73 74 |
# File 'lib/depix/binary/fields.rb', line 72 def length 4 end |
#pattern ⇒ Object
68 69 70 |
# File 'lib/depix/binary/fields.rb', line 68 def pattern "N" end |
#validate!(value) ⇒ Object
Override - might be Bignum although cast to Integer sometimes
81 82 83 84 85 |
# File 'lib/depix/binary/fields.rb', line 81 def validate!(value) raise "#{name} value required, but got nil".strip if value.nil? && req? raise "#{name} value expected to be #{rtype} but was #{value.class}" if !value.nil? && (!value.is_a?(Integer) && !value.is_a?(Bignum)) raise "#{name} value #{value} overflows" if !value.nil? && (value < 0 || value >= BLANK) end |