class FMOD::Core::Structure

@abstract Expands upon a the built-in Fiddle::CStructEntity to provide some additional common functionality for FMOD structures.

Public Class Methods

new(address, types, members) click to toggle source

@param address [Integer, String] The memory address of the structure as

an integer or packed binary string.

@param types [Array<Integer>] Array of primitive C-type flags for the

data type used by each field.

@param members [Array<Symbol>] Array of names as symbols to use for the

fields.
Calls superclass method
# File lib/fmod/core/structure.rb, line 21
def initialize(address, types, members)
  address = Pointer[address] if address.is_a?(String)
  address ||= Fiddle.malloc(self.class.size(types)).to_i
  super(address, types)
  assign_names members
end

Public Instance Methods

inspect() click to toggle source

@return [String] the structure as a string.

Calls superclass method
# File lib/fmod/core/structure.rb, line 44
def inspect
  values = @members.map { |sym| "#{sym}=#{self[sym]}"}.join(', ')
  super.sub(/free=0x(.)*/, values << '>')
end
names() click to toggle source

@return [Array<Symbol>] the names of the structure's fields as symbols. @since 0.9.1

# File lib/fmod/core/structure.rb, line 31
def names
  @members
end
values() click to toggle source

@return [Array<Object>] the values of the structure's fields. @since 0.9.1

# File lib/fmod/core/structure.rb, line 38
def values
  @members.map { |sym| self[sym] }
end