Class: Depix::Binary::Fields::U8Field

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

Overview

uint8 field

Constant Summary collapse

BLANK =
0xFF

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



107
108
109
# File 'lib/depix/binary/fields.rb', line 107

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

#lengthObject



99
100
101
# File 'lib/depix/binary/fields.rb', line 99

def length
  1
end

#patternObject



95
96
97
# File 'lib/depix/binary/fields.rb', line 95

def pattern
  "c"
end

#rtypeObject



103
104
105
# File 'lib/depix/binary/fields.rb', line 103

def rtype
  Integer
end

#validate!(value) ⇒ Object



111
112
113
114
# File 'lib/depix/binary/fields.rb', line 111

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