class FMOD::Sound::TagCollection

Emulates an Array-type container of a {Tag}'s objects within a {Sound}.

Public Class Methods

new(sound) click to toggle source
# File lib/fmod/sound.rb, line 778
def initialize(sound)
  @sound = sound
end

Public Instance Methods

[](index) click to toggle source

Retrieves a descriptive tag stored by the sound, to describe things like the song name, author etc.

@param index [Integer] Index into the collection to retrieve the tag.

@return [Tag, nil] the desired {Tag} or nil if index is out of range.

# 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
Also aliased as: tag
count() click to toggle source

@!attribute [r] count @return [Integer] the number of tags in the collection.

# 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
Also aliased as: size
each() { |self| ... } click to toggle source
# 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
size()
Alias for: count
tag(index)
Alias for: []
updated_count() click to toggle source

@!attribute [r] count @return [Integer] the number of updated tags in the collection since

last time this value was checked.
# 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