Class: FMOD::Sound::TagCollection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#countInteger (readonly) Also known as: size

Returns the number of updated tags in the collection since last time this value was checked.

Returns:

  • (Integer)

    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.

Parameters:

  • index (Integer)

    Index into the collection to retrieve the tag.

Returns:

  • (Tag, nil)

    the desired Core::Tag or nil if index is out of range.



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

#eachObject



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_countInteger

Returns the number of updated tags in the collection since last time this value was checked.

Returns:

  • (Integer)

    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