Module: StructPacking::Unpackable::ClassMethods

Defined in:
lib/struct_packing/unpackable.rb

Overview

Extending methods for Unpackable class.

Automatically extend on including StructPacking::Unpackable module.

Instance Method Summary collapse

Instance Method Details

#unpack(bytes) ⇒ Object Also known as: from_data

Construct object byte array.

This method is simply do object construct and values assignment. If attribute defined in byte_format, but object has no attr_setter, do nothing.

TODO: Including class must have default constructor.

  • bytes packed structure. (see Packable.pack)



33
34
35
36
# File 'lib/struct_packing/unpackable.rb', line 33

def unpack(bytes)  
  obj = self.new
  set_values_from_byte_to_object(bytes, obj)
end