Class: Zippo::BinaryStructure::BinaryPacker
- Inherits:
-
Object
- Object
- Zippo::BinaryStructure::BinaryPacker
- Defined in:
- lib/zippo/binary_structure/binary_packer.rb
Class Attribute Summary collapse
-
.structure ⇒ Object
Returns the value of attribute structure.
Instance Method Summary collapse
-
#initialize(io) ⇒ BinaryPacker
constructor
A new instance of BinaryPacker.
- #pack(obj) ⇒ Object
Constructor Details
#initialize(io) ⇒ BinaryPacker
Returns a new instance of BinaryPacker.
8 9 10 |
# File 'lib/zippo/binary_structure/binary_packer.rb', line 8 def initialize(io) @io = io end |
Class Attribute Details
.structure ⇒ Object
Returns the value of attribute structure.
5 6 7 |
# File 'lib/zippo/binary_structure/binary_packer.rb', line 5 def structure @structure end |
Instance Method Details
#pack(obj) ⇒ Object
12 13 14 |
# File 'lib/zippo/binary_structure/binary_packer.rb', line 12 def pack(obj) @io << self.class.structure.fields.map { |f| obj.send f.name }.pack(self.class.structure.fields.map(&:pack).join("")) end |