Class: Mp3file::ID3v2::Header
- Inherits:
-
Object
- Object
- Mp3file::ID3v2::Header
- Defined in:
- lib/mp3file/id3v2/header.rb
Defined Under Namespace
Classes: ID3v2HeaderFormat
Instance Attribute Summary collapse
-
#compression ⇒ Object
readonly
Returns the value of attribute compression.
-
#experimental ⇒ Object
readonly
Returns the value of attribute experimental.
-
#extended_header ⇒ Object
readonly
Returns the value of attribute extended_header.
-
#footer ⇒ Object
readonly
Returns the value of attribute footer.
-
#tag_size ⇒ Object
readonly
Returns the value of attribute tag_size.
-
#unsynchronized ⇒ Object
readonly
Returns the value of attribute unsynchronized.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(io) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(io) ⇒ Header
Returns a new instance of Header.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/mp3file/id3v2/header.rb', line 26 def initialize(io) header = nil begin header = ID3v2HeaderFormat.read(io) rescue BinData::ValidityError => ve raise InvalidID3v2TagError, ve. end @version = Version.new(header.vmaj, header.vmin) @unsynchronized = false @extended_header = false @compression = false @experimental = false @footer = false if @version >= ID3V2_2_0 && @version < ID3V2_3_0 @unsynchronized = header.unsynchronized == 1 # Bit 6 was redefined in v2.3.0+, and we picked the new name # for it above. @compression = header.extended_header == 1 if header.experimental == 1 || header. == 1 raise InvalidID3v2TagError, "Invalid flag set in ID3v2.2 header" end elsif @version >= ID3V2_3_0 && @version < ID3V2_4_0 @unsynchronized = header.unsynchronized == 1 @extended_header = header.extended_header == 1 @experimental = header.experimental == 1 if header. == 1 raise InvalidID3v2TagError, "Invalid flag set in ID3v2.3 header" end elsif @version >= ID3V2_4_0 @unsynchronized = header.unsynchronized == 1 @extended_header = header.extended_header == 1 @experimental = header.experimental == 1 @footer = header. == 1 end @tag_size = BitPaddedInt.unpad_number(header.size_padded) end |
Instance Attribute Details
#compression ⇒ Object (readonly)
Returns the value of attribute compression.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def compression @compression end |
#experimental ⇒ Object (readonly)
Returns the value of attribute experimental.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def experimental @experimental end |
#extended_header ⇒ Object (readonly)
Returns the value of attribute extended_header.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def extended_header @extended_header end |
#footer ⇒ Object (readonly)
Returns the value of attribute footer.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def @footer end |
#tag_size ⇒ Object (readonly)
Returns the value of attribute tag_size.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def tag_size @tag_size end |
#unsynchronized ⇒ Object (readonly)
Returns the value of attribute unsynchronized.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def unsynchronized @unsynchronized end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/mp3file/id3v2/header.rb', line 3 def version @version end |