Method: TagLib::FileRef.open

Defined in:
docs/taglib/base.rb

.open(filename, read_audio_properties = true, audio_properties_style = TagLib::AudioProperties::Average) {|file| ... } ⇒ Object

Creates a new file and passes it to the provided block, closing the file automatically at the end of the block.

Note that after the block is done, the file is closed and all memory is released for objects read from the file (basically everything from the TagLib namespace).

Using open is preferable to using new and then manually close.

Examples:

Reading a title

title = TagLib::FileRef.open("file.oga") do |file|
  tag = file.tag
  tag.title
end

Parameters:

  • (defaults to: true)

    true if audio properties should be read

  • (defaults to: TagLib::AudioProperties::Average)

    how accurately the audio properties should be read, e.g. AudioProperties::Average

Yields:

Returns:

  • the return value of the block

Since:

  • 0.4.0



111
112
113
# File 'docs/taglib/base.rb', line 111

def self.open(filename, read_audio_properties=true,
               audio_properties_style=TagLib::AudioProperties::Average)
end