Module: StructPacking::Unpackable

Includes:
Base
Defined in:
lib/struct_packing/unpackable.rb

Overview

Unpackable module provides value assign function from packed byte array.

A class include this module, and call struct defininesg method, A instance’s unpack method assign variables from packed object. This module also provide read_struct_data class method which construct object and assign values from packed object.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Base

#pack_template

Instance Method Details

#read_struct_data(bytes) ⇒ Object

Set attributes from packed struct byte array.

If attribute defined in byte_format, but object has no attr_setter, do nothing.



134
135
136
# File 'lib/struct_packing/unpackable.rb', line 134

def read_struct_data(bytes)
  self.class.set_values_from_byte_to_object(bytes, self)
end