Class: FMOD::Sound::TagCollection
- Inherits:
-
Object
- Object
- FMOD::Sound::TagCollection
- Includes:
- Enumerable
- Defined in:
- lib/fmod/sound.rb
Overview
Emulates an Array-type container of a Core::Tag‘s objects within a FMOD::Sound.
Instance Attribute Summary collapse
-
#count ⇒ Integer
(also: #size)
readonly
The number of updated tags in the collection since last time this value was checked.
Instance Method Summary collapse
-
#[](index) ⇒ Tag?
(also: #tag)
Retrieves a descriptive tag stored by the sound, to describe things like the song name, author etc.
- #each ⇒ Object
-
#initialize(sound) ⇒ TagCollection
constructor
A new instance of TagCollection.
-
#updated_count ⇒ Integer
The number of updated tags in the collection since last time this value was checked.
Constructor Details
#initialize(sound) ⇒ TagCollection
Returns a new instance of TagCollection.
778 779 780 |
# File 'lib/fmod/sound.rb', line 778 def initialize(sound) @sound = sound end |
Instance Attribute Details
#count ⇒ Integer (readonly) Also known as: size
Returns the number of updated tags in the collection since last time this value was checked.
791 792 793 794 795 |
# File 'lib/fmod/sound.rb', line 791 def count buffer = "\0" * Fiddle::SIZEOF_INT FMOD.invoke(:Sound_GetNumTags, @sound, buffer, nil) buffer.unpack1('l') end |
Instance Method Details
#[](index) ⇒ Tag? Also known as: tag
Retrieves a descriptive tag stored by the sound, to describe things like the song name, author etc.
816 817 818 819 820 821 822 823 824 825 |
# File 'lib/fmod/sound.rb', line 816 def [](index) tag = FMOD::Core::Tag.new if index.is_a?(Integer) return nil unless index.between?(0, count - 1) FMOD.invoke(:Sound_GetTag, @sound, nil, index, tag) elsif tag.is_a?(String) FMOD.invoke(:Sound_GetTag, @sound, index, 0, tag) end tag end |
#each ⇒ Object
782 783 784 785 786 |
# File 'lib/fmod/sound.rb', line 782 def each return to_enum(:each) unless block_given? (0...count).each { |i| yield self[i] } self end |
#updated_count ⇒ Integer
Returns the number of updated tags in the collection since last time this value was checked.
803 804 805 806 807 |
# File 'lib/fmod/sound.rb', line 803 def updated_count buffer = "\0" * Fiddle::SIZEOF_INT FMOD.invoke(:Sound_GetNumTags, @sound, nil, buffer) buffer.unpack1('l') end |