Class: Bytepack::TypeInfo
- Extended by:
- Extensions::CodeValuesHash
- Defined in:
- lib/bytepack/type_info.rb
Constant Summary
Constants inherited from Byte
Byte::DIRECTIVE, Byte::LENGTH, Byte::NULL_INDICATOR
Instance Attribute Summary
Attributes included from Extensions::CodeValuesHash
Class Method Summary collapse
Methods included from Extensions::CodeValuesHash
Methods inherited from Basic
bytesToInt, intToBytes, preprocess
Methods inherited from Struct
classifyDataType, config, packingDataType, single_type_array?, testpacking
Class Method Details
.pack(val) ⇒ Object
21 22 23 24 |
# File 'lib/bytepack/type_info.rb', line 21 def pack(val) val = val.is_a?(::Integer) ? val : code_values[val]||CustomData.code_by_struct(val) super(val) end |
.unpack(bytes, offset = 0) ⇒ Object
26 27 28 29 30 |
# File 'lib/bytepack/type_info.rb', line 26 def unpack(bytes, offset = 0) unpacked = super(bytes, offset) unpacked[0] = codes[unpacked[0]]||CustomData.struct_by_code(unpacked[0]) if unpacked[0] unpacked end |