class Ronin::Support::Binary::CTypes::AggregateType
Base class for all aggregate types.
@api private
@since 1.0.0
Public Instance Methods
length()
click to toggle source
The number of elements within the aggregate type.
@return [Integer, Float::INFINITY]
@abstract
# File lib/ronin/support/binary/ctypes/aggregate_type.rb, line 41 def length raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end
pack(value)
click to toggle source
Packs the value into the aggregate type’s binary format.
@param [Integer, Float
, String] value
The value to pack.
@return [String]
The packed binary data.
@raise [NotImplementedError]
{#pack_string} was not set.
@api public
# File lib/ronin/support/binary/ctypes/aggregate_type.rb, line 59 def pack(value) if @pack_string values = [] enqueue_value(values,value) return values.pack(@pack_string) else raise(NotImplementedError,"#{self.class} does not define a #pack_string") end end
unpack(data)
click to toggle source
Unpacks the binary data.
@param [String] data
The binary data to unpack.
@return [Integer, Float
, String
, nil]
The unpacked value.
@raise [NotImplementedError]
{#pack_string} was not set.
@api public
# File lib/ronin/support/binary/ctypes/aggregate_type.rb, line 84 def unpack(data) if @pack_string values = data.unpack(@pack_string) return dequeue_value(values) else raise(NotImplementedError,"#{self.class} does not define a #pack_string") end end