Class: TagLib::MP4::ItemMap

Inherits:
Object
  • Object
show all
Defined in:
docs/taglib/mp4.rb

Overview

The underlying C++-structure of ItemMap inherits from std::map. Consequently, ItemMap behaves differently from a Ruby hash in a few places: the C++ memory management strategies of ItemMap can lead to a situation where a Ruby object refers to a location in memory that was freed by C++. To prevent Ruby from crashing on us with a segmentation fault, we raise an ObjectPreviouslyDeleted exception when we try to access data that is no longer available.

Instance Method Summary collapse

Instance Method Details

#clearnil

Note:

May free memory referred to by Ruby objects

Remove all Items from self, destroying each Item.

Examples:

Triggering an ObjectPreviouslyDeleted exception

remember_me = mp4.tag.item_list_map["\xC2\xA9nam"]
mp4.tag.item_list_map.clear
# => nil
remember_me.to_string_list
# ObjectPreviouslyDeleted: Expected argument 0 of type TagLib::MP4::Item const *, but got TagLib::MP4::Item #<TagLib::MP4::Item:0x007f9199...
# 	in SWIG method 'toStringList'
# from (pry):7:in `to_string_list'

Returns:

  • (nil)


268
269
# File 'docs/taglib/mp4.rb', line 268

def clear
end

#contains(key) ⇒ Boolean Also known as: has_key?, include?

Returns true if self has an Item under key.

Parameters:

  • key (String)

Returns:

  • (Boolean)


274
275
# File 'docs/taglib/mp4.rb', line 274

def contains(key)
end

#empty?Boolean

Returns true if self is empty

Returns:

  • (Boolean)


281
282
# File 'docs/taglib/mp4.rb', line 281

def empty?
end

#erase(key) ⇒ nil

Note:

May free memory referred to by Ruby objects

Remove and destroy the value under key, if present.

Examples:

Triggering an ObjectPreviouslyDeleted exception

remember_me = mp4.tag.item_list_map["\xC2\xA9nam"]
mp4.tag.item_list_map.erase("\xC2\xA9nam")
# => nil
remember_me.to_string_list
# ObjectPreviouslyDeleted: Expected argument 0 of type TagLib::MP4::Item const *, but got TagLib::MP4::Item #<TagLib::MP4::Item:0x007f919a...
# 	in SWIG method 'toStringList'
# from (pry):13:in `to_string_list'

Parameters:

  • key (String)

Returns:

  • (nil)


297
298
# File 'docs/taglib/mp4.rb', line 297

def erase(key)
end

#fetch(key) ⇒ TagLib::MP4::Item? Also known as: []

Return the Item under key, or nil if no Item is present.

Parameters:

  • key (String)

Returns:



252
253
# File 'docs/taglib/mp4.rb', line 252

def fetch(key)
end

#insert(key, item) ⇒ nil

Note:

May free memory referred to by Ruby objects

Insert an item at key, destoying the existing item under key.

Examples:

Triggering an ObjectPreviouslyDeleted exception

remember_me = mp4.tag.item_list_map["\xC2\xA9nam"]
mp4.tag.item_list_map.insert("\xC2\xA9nam", TagLib::MP4::Item.from_string_list(['New']))
remember_me.to_string_list
# ObjectPreviouslyDeleted: Expected argument 0 of type TagLib::MP4::Item const *, but got TagLib::MP4::Item #<TagLib::MP4::Item:0x007f919a...
# 	in SWIG method 'toStringList'
# from (pry):18:in `to_string_list'

Parameters:

Returns:

  • (nil)


312
313
# File 'docs/taglib/mp4.rb', line 312

def insert(key, item)
end

#sizeFixnum

The number of Items in self.

Returns:

  • (Fixnum)


317
318
# File 'docs/taglib/mp4.rb', line 317

def size
end

#to_aArray<Array<String, TagLib::MP4::Item>>

Convert self into an array of [key, value] pairs.

Returns:



322
323
# File 'docs/taglib/mp4.rb', line 322

def to_a
end

#to_hHash<String, TagLib::MP4::Item>

Convert self into an hash.

Returns:

Since:

  • 1.0.0



329
330
# File 'docs/taglib/mp4.rb', line 329

def to_h
end