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
82 def initialize(filename)
83   @filename = filename.to_s
84 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
90 def exists?
91   begin
92     fields
93     true
94   rescue InvalidDataError
95     false
96   end
97 end
fields()

Get all the fields in the vorbis comment

[show source]
    # File vorbis_comment.rb
105 def fields
106   return @fields if @fields
107   @fields = CICPHash.new
108   read_fields
109   @fields
110 end
pretty_print()

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

[show source]
    # File vorbis_comment.rb
113 def pretty_print
114   begin
115     fields.sort.collect{|key, value| "#{key}: #{value.join(', ')}"}.join("\n")
116   rescue OpenError
117     "FILE NOT FOUND!"
118   rescue InvalidDataError, InvalidCommentError
119     "CORRUPT TAG!"
120   end
121 end
remove!()

Clear all fields from the vorbis comment

[show source]
    # File vorbis_comment.rb
100 def remove!
101   update{|fields| fields.clear}
102 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
125 def update(&block)
126   yield fields
127   write_fields(normalize_fields)
128   fields
129 end