Class: ApeTag
- Inherits:
-
Object
- Object
- ApeTag
- Defined in:
- lib/audioinfo/apetag.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(filename) ⇒ ApeTag
constructor
A new instance of ApeTag.
Constructor Details
#initialize(filename) ⇒ ApeTag
Returns a new instance of ApeTag.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/audioinfo/apetag.rb', line 8 def initialize(filename) @tag = {} begin @file = File.new(filename, "rb") @file.seek(-32, IO::SEEK_END) preamble, version, , itemcount, flags = @file.read(24).unpack("A8VVVV") @version = version/1000 raise(ApeTagError, "cannot find preamble") if preamble != 'APETAGEX' @file.seek(-, IO::SEEK_END) itemcount.times do |i| len, flags = @file.read(8).unpack("VV") key = "" loop do c = @file.getc break if c == 0 key << c end #ugly FIX @tag[key.downcase] = @file.read(len) unless len > 100_000 end ensure @file.close end end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
6 7 8 |
# File 'lib/audioinfo/apetag.rb', line 6 def tag @tag end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/audioinfo/apetag.rb', line 6 def version @version end |