Class: Depix::Binary::Fields::U16Field

Inherits:
Field
  • Object
show all
Defined in:
lib/depix/binary/fields.rb

Overview

uint16 field

Constant Summary collapse

BLANK =
0xFFFF

Instance Attribute Summary

Attributes inherited from Field

#desc, #name, #req

Instance Method Summary collapse

Methods inherited from Field

#consume!, #explain, #initialize, #pack

Constructor Details

This class inherits a constructor from Depix::Binary::Fields::Field

Instance Method Details

#clean(v) ⇒ Object



151
152
153
# File 'lib/depix/binary/fields.rb', line 151

def clean(v)
  (v == BLANK || v == -1) ? nil : v
end

#lengthObject



143
144
145
# File 'lib/depix/binary/fields.rb', line 143

def length
  2
end

#patternObject



139
140
141
# File 'lib/depix/binary/fields.rb', line 139

def pattern
  "n"
end

#rtypeObject



147
148
149
# File 'lib/depix/binary/fields.rb', line 147

def rtype
  Integer
end

#validate!(value) ⇒ Object



155
156
157
158
# File 'lib/depix/binary/fields.rb', line 155

def validate!(value)
  super(value)
  raise "#{name} value #{value} out of bounds for 16bit unsigned int" if (value < 0 || value >= BLANK)
end