Module: Zippo::BinaryStructure

Defined in:
lib/zippo/binary_structure/base.rb,
lib/zippo/binary_structure/meta.rb,
lib/zippo/binary_structure/structure.rb,
lib/zippo/binary_structure/binary_packer.rb,
lib/zippo/binary_structure/binary_unpacker.rb,
lib/zippo/binary_structure/structure_member.rb

Overview

BinaryStructure defines a class level DSL for implementing binary strucutures.

The class will then have an ::Unpacker and ::Packer class defined underneath it that can be used to read and write the defined fields from an io.

The DSL itself is fairly simple, fields are defined with a field name, “packing code” (per standard ruby Array#pack) and possibly options.

  • the :signature option indicates the field is a fixed signature

  • the :size => <field> option indicates the field is a variable width size field, with the size previously recorded in the specified field

Examples:

binary_structure do
  field :foo, 'L'
  field :yay, 'a4', :signature => "baz"
  field :bar, 'S'
  field :quux, 'a*', :size => :foo
end

See Also:

  • Array#pack

Defined Under Namespace

Modules: Base, CodeGen, InstanceMethods Classes: BinaryPacker, BinaryUnpacker, Structure, StructureMember