class FMOD::Core::Tag

Structure describing a piece of tag data.

Constants

ID3V1_GENRES

Strings for ID3v1 tags that use a number to represent the genre. That number can be used as an index into this array to retrieve the name for the genre.

@since 0.9.2

Public Class Methods

new(address = nil) click to toggle source

@param address [Pointer, Integer, String, nil] The address in memory

where the structure will be created from. If no address is given, new
memory will be allocated.
Calls superclass method FMOD::Core::Structure::new
# File lib/fmod/core/tag.rb, line 50
def initialize(address = nil)
  types = [TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_INT]
  members = [:type, :data_type, :name, :data, :data_length, :updated]
  super(address, types, members)
end

Public Instance Methods

name() click to toggle source

@!attribute [r] name @return [String] the name of this tag i.e. “TITLE”, “ARTIST” etc.

# File lib/fmod/core/tag.rb, line 77
def name
  self[:name].to_s
end
updated?() click to toggle source

@return [Boolean] a flag indicating if this tag has been updated sinc

last being accessed.
# File lib/fmod/core/tag.rb, line 84
def updated?
  self[:updated] != 0
end
value() click to toggle source

Retrieves the tag data, which can vary depending on the value specified in {#data_type}. @return [String, Float, Integer] the tag data. @see TagDataType

# File lib/fmod/core/tag.rb, line 93
def value
  raw = self[:data].to_s(self[:data_length])
  raw.delete!("\0") unless self[:data_type] == TagDataType::BINARY
  # noinspection RubyResolve
  case self[:data_type]
  when TagDataType::BINARY then raw
  when TagDataType::INT then raw.unpack1('l')
  when TagDataType::FLOAT then raw.unpack1('f')
  when TagDataType::STRING then raw.force_encoding('ASCII')
  when TagDataType::STRING_UTF8 then raw.force_encoding(Encoding::UTF_8)
  when TagDataType::STRING_UTF16 then raw.force_encoding(Encoding::UTF_16)
  when TagDataType::STRING_UTF16BE then raw.force_encoding(Encoding::UTF_16BE)
  else ''
  end
end