Class: Vorbis::Info
- Inherits:
-
Object
- Object
- Vorbis::Info
- Defined in:
- lib/vorbis.rb
Overview
This class reads metadata (such as comments/tags and bitrate) from Vorbis audio files. Here’s an example of usage:
require 'vorbis'
Vorbis::Info.open('echoplex.ogg') do |info|
info.comments[:artist].first #=> "Nine Inch Nails"
info.comments[:title].first #=> "Echoplex"
info.sample_rate #=> 44100
end
You may notice that for each comment field an array of values is available. This is because it is perfectly valid for a Vorbis file to have multiple artists, titles, or anything else.
Instance Attribute Summary collapse
-
#bitrate ⇒ Object
readonly
Returns the value of attribute bitrate.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#comment_header ⇒ Object
readonly
Returns the value of attribute comment_header.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#identification_header ⇒ Object
readonly
Returns the value of attribute identification_header.
-
#nominal_bitrate ⇒ Object
readonly
Returns the value of attribute nominal_bitrate.
-
#sample_rate ⇒ Object
readonly
Returns the value of attribute sample_rate.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, container = :ogg) {|_self| ... } ⇒ Info
constructor
Create a new Vorbis::Info object for reading metadata.
Constructor Details
#initialize(path, container = :ogg) {|_self| ... } ⇒ Info
Create a new Vorbis::Info object for reading metadata.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vorbis.rb', line 24 def initialize(path, container=:ogg) if path.is_a? IO @io = path else @io = open(path, 'rb') end case container when :ogg init_ogg else raise "#{container.to_s} is not a supported container format" end @io.close yield self if block_given? end |
Instance Attribute Details
#bitrate ⇒ Object (readonly)
Returns the value of attribute bitrate.
21 22 23 |
# File 'lib/vorbis.rb', line 21 def bitrate @bitrate end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
21 22 23 |
# File 'lib/vorbis.rb', line 21 def channels @channels end |
#comment_header ⇒ Object (readonly)
Returns the value of attribute comment_header.
19 20 21 |
# File 'lib/vorbis.rb', line 19 def comment_header @comment_header end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
20 21 22 |
# File 'lib/vorbis.rb', line 20 def comments @comments end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
21 22 23 |
# File 'lib/vorbis.rb', line 21 def duration @duration end |
#identification_header ⇒ Object (readonly)
Returns the value of attribute identification_header.
19 20 21 |
# File 'lib/vorbis.rb', line 19 def identification_header @identification_header end |
#nominal_bitrate ⇒ Object (readonly)
Returns the value of attribute nominal_bitrate.
21 22 23 |
# File 'lib/vorbis.rb', line 21 def nominal_bitrate @nominal_bitrate end |
#sample_rate ⇒ Object (readonly)
Returns the value of attribute sample_rate.
21 22 23 |
# File 'lib/vorbis.rb', line 21 def sample_rate @sample_rate end |
Class Method Details
.open(*args, &block) ⇒ Object
43 44 45 |
# File 'lib/vorbis.rb', line 43 def self.open(*args, &block) return self.new(*args, &block) end |