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)

270
271
# File 'docs/taglib/mp4.rb', line 270

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)

276
277
# File 'docs/taglib/mp4.rb', line 276

def contains(key)
end

#empty?Boolean

Returns true if self is empty

Returns:

  • (Boolean)

283
284
# File 'docs/taglib/mp4.rb', line 283

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)

299
300
# File 'docs/taglib/mp4.rb', line 299

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:


254
255
# File 'docs/taglib/mp4.rb', line 254

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)

314
315
# File 'docs/taglib/mp4.rb', line 314

def insert(key, item)
end

#sizeFixnum

The number of Items in self.

Returns:

  • (Fixnum)

319
320
# File 'docs/taglib/mp4.rb', line 319

def size
end

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

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

Returns:


324
325
# File 'docs/taglib/mp4.rb', line 324

def to_a
end

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

Convert self into an hash.

Returns:

Since:

  • 1.0.0


331
332
# File 'docs/taglib/mp4.rb', line 331

def to_h
end