Class: FMOD::Core::Structure Abstract
- Inherits:
-
Fiddle::CStructEntity
- Object
- Fiddle::CStructEntity
- FMOD::Core::Structure
- Includes:
- FMOD::Core, Fiddle
- Defined in:
- lib/fmod/core/structure.rb
Overview
This class is abstract.
Expands upon a the built-in Fiddle::CStructEntity to provide some additional common functionality for FMOD structures.
Direct Known Subclasses
AdvancedSettings, BoolDescription, DataDescription, DspDescription, FloatDescription, Guid, IntegerDescription, ParameterInfo, Reverb, SoundExInfo, SpectrumData, Tag, Vector
Instance Method Summary collapse
-
#initialize(address, types, members) ⇒ Structure
constructor
A new instance of Structure.
-
#inspect ⇒ String
The structure as a string.
-
#names ⇒ Array<Symbol>
The names of the structure’s fields as symbols.
-
#values ⇒ Array<Object>
The values of the structure’s fields.
Constructor Details
#initialize(address, types, members) ⇒ Structure
Returns a new instance of Structure.
21 22 23 24 25 26 |
# 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 |
Instance Method Details
#inspect ⇒ String
Returns the structure as a string.
44 45 46 47 |
# 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 ⇒ Array<Symbol>
Returns the names of the structure’s fields as symbols.
31 32 33 |
# File 'lib/fmod/core/structure.rb', line 31 def names @members end |
#values ⇒ Array<Object>
Returns the values of the structure’s fields.
38 39 40 |
# File 'lib/fmod/core/structure.rb', line 38 def values @members.map { |sym| self[sym] } end |