def pack_value(val, obj=nil)
        begin
          if @pack_cb
            @pack_cb.call(val, obj)
          else
            varray = val.is_a?(Array) ? val : [val]
            varray.pack(self.format)
          end
        rescue => e
          raise(PackError, "Error packing #{val.inspect} as type #{self.name.inspect} -- #{e.class} -> #{e}")
        end
      end
def pack_value(val, obj=nil)
        begin
          if @pack_cb
            @pack_cb.call(val, obj)
          else
            varray = val.is_a?(Array) ? val : [val]
            varray.pack(self.format)
          end
        rescue => e
          raise(PackError, "Error packing #{val.inspect} as type #{self.name.inspect} -- #{e.class} -> #{e}")
        end
      end
Called when composing raw data. While you can override this in
 subclasses, in general it is probably better to use the 'on_pack'
 method to define a proc to handle packing for special cases.