Class: Id3Taginator::Header::Id3v24ExtendedHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/id3taginator/header/id3v24_extended_header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size, flags) ⇒ Id3v24ExtendedHeader

constructor

Parameters:

  • size (Integer)

    the size of the extended header

  • flags (String)

    2 byte Array as a String representing the flags



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 13

def initialize(size, flags)
  @size = size
  @flags = flags
  @tag_is_update = false
  @crc_data = nil
  @restrictions = 0b00000000

  flags_stream = StringIO.new(flags)
  ext_flag = flags_stream.readbyte
  # tag is update
  if bit_set?(ext_flag, 0b01000000)
    @tag_is_update = true
    flags_stream.readbyte
  end

  # crc data
  if bit_set?(ext_flag, 0b00100000)
    length = ext_flag.readbyte
    @crc_data = flags_stream.read(length)
  end

  ext_flag.readbyte if bit_set?(ext_flag, 0b00010000)
  @restrictions = ext_flag.readbyte if bit_set?(ext_flag, 0b00010000)
end

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



7
8
9
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 7

def flags
  @flags
end

#sizeObject

Returns the value of attribute size.



7
8
9
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 7

def size
  @size
end

Instance Method Details

#crcString?

returns the CRC data if present

Returns:

  • (String, nil)

    the CRC data



48
49
50
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 48

def crc
  @crc_data
end

#image_encoding_restrictions?Boolean

determined if the tag is encoding restricted

Returns:

  • (Boolean)

    true if encoding restricted, else false



76
77
78
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 76

def image_encoding_restrictions?
  (@restrictions & 0b00000100) == 0b00000100
end

#image_size_restrictions?Boolean

determined if the tag is image encoding restricted

Returns:

  • (Boolean)

    true if image encoding restricted, else false



83
84
85
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 83

def image_size_restrictions?
  (@restrictions & 0b00000011) == 0b00000011
end

#tag_is_an_update?Boolean

determined if the tag is an update

Returns:

  • (Boolean)

    true if it is an update, else false



41
42
43
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 41

def tag_is_an_update?
  @tag_is_update
end

#tag_size_restrictions?Boolean

determined if the tag is size restricted

Returns:

  • (Boolean)

    true if it restricted, else false



55
56
57
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 55

def tag_size_restrictions?
  (@restrictions & 0b11000000) == 0b11000000
end

#text_encoding_restrictions?Boolean

determined if the tag is text encoding restricted

Returns:

  • (Boolean)

    true if text encoding restricted, else false



62
63
64
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 62

def text_encoding_restrictions?
  (@restrictions & 0b00100000) == 0b00100000
end

#text_fields_size_restrictions?Boolean

determined if the tag is fields size restricted

Returns:

  • (Boolean)

    true if fields size restricted, else false



69
70
71
# File 'lib/id3taginator/header/id3v24_extended_header.rb', line 69

def text_fields_size_restrictions?
  (@restrictions & 0b00011000) == 0b00011000
end