class VorbisComment

  1. vorbis_comment.rb
Superclass: Object

Contains all of the Vorbis comment fields found in the filename/file given.

Methods

Public Class

  1. new

Public Instance

  1. exists?
  2. fields
  3. filename
  4. pretty_print
  5. remove!
  6. update

Constants

BAD_KEY_RE = /[\x00-\x1f=\x7e-\xff]/n  

Attributes

filename [R]

Public Class methods

new (filename)

Set the filename to be used

[show source]
# File vorbis_comment.rb, line 81
def initialize(filename)
  @filename = filename.to_s
end

Public Instance methods

exists? ()

Check for the existance of the a vorbis comment in the file. Because all Vorbis bitstreams should have a comment, any file missing a comment probably isn't a vorbis file, or it's possible the file is corrupt.

[show source]
# File vorbis_comment.rb, line 89
def exists?
  begin
    fields
    true
  rescue InvalidDataError
    false
  end
end
fields ()

Get all the fields in the vorbis comment

[show source]
# File vorbis_comment.rb, line 104
def fields
  return @fields if @fields
  @fields = CICPHash.new
  read_fields
  @fields
end
pretty_print ()

Return a string suitable for pretty printing, used by the command line

[show source]
# File vorbis_comment.rb, line 112
def pretty_print
  begin
    fields.sort.collect{|key, value| "#{key}: #{value.join(', ')}"}.join("\n")
  rescue OpenError
    "FILE NOT FOUND!"
  rescue InvalidDataError, InvalidCommentError
    "CORRUPT TAG!"
  end
end
remove! ()

Clear all fields from the vorbis comment

[show source]
# File vorbis_comment.rb, line 99
def remove!
  update{|fields| fields.clear}
end
update (&block)

Update the vorbis comment with the changes that occur to fields inside the block. Make sure to modify the fields given and not reassign them.

[show source]
# File vorbis_comment.rb, line 124
def update(&block)
  yield fields
  write_fields(normalize_fields)
  fields
end