Class: Id3Taginator::Header::Id3v2Flags

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

Instance Method Summary collapse

Constructor Details

#initialize(flags) ⇒ Id3v2Flags

constructor

Parameters:

  • flags (Integer)

    the 1 byte header flag



10
11
12
# File 'lib/id3taginator/header/id3v2_flags.rb', line 10

def initialize(flags)
  @flags = flags
end

Instance Method Details

#experimental?Boolean

determines if experimental tags are present

Returns:

  • (Boolean)

    true if experimental tags present, else false



38
39
40
# File 'lib/id3taginator/header/id3v2_flags.rb', line 38

def experimental?
  (@flags & 0b0010_0000) == 0b0010_0000
end

#extended_header?Boolean

determines if an extended header is present

Returns:

  • (Boolean)

    true if header is present, else false



31
32
33
# File 'lib/id3taginator/header/id3v2_flags.rb', line 31

def extended_header?
  (@flags & 0b0100_0000) == 0b0100_0000
end

#footer=(enabled) ⇒ Object

enables or disables a footer

Parameters:

  • enabled (Boolean)

    true, if the footer should be set to the tag, else false



52
53
54
# File 'lib/id3taginator/header/id3v2_flags.rb', line 52

def footer=(enabled)
  @flags = enabled ? @flags | 0b0001_0000 : @flags & 0b1110_1111
end

#footer?Boolean

determines if a footer is present

Returns:

  • (Boolean)

    true if a footer is present, else false



45
46
47
# File 'lib/id3taginator/header/id3v2_flags.rb', line 45

def footer?
  (@flags & 0b0001_0000) == 0b0001_0000
end

#to_bytesString

dumps the flags to a byte string

Returns:

  • (String)

    the String representing the flags



59
60
61
# File 'lib/id3taginator/header/id3v2_flags.rb', line 59

def to_bytes
  @flags.chr
end

#unsynchronized=(enabled) ⇒ Object

enables or synchronization for the tag

Parameters:

  • enabled (Boolean)

    true, if tag should be synchronized, else false



24
25
26
# File 'lib/id3taginator/header/id3v2_flags.rb', line 24

def unsynchronized=(enabled)
  @flags = enabled ? @flags | 0b1000_0000 : @flags & 0b0111_1111
end

#unsynchronized?Boolean

determined if the tag is unsynchronized

Returns:

  • (Boolean)

    true if unsynchronized, else false



17
18
19
# File 'lib/id3taginator/header/id3v2_flags.rb', line 17

def unsynchronized?
  (@flags & 0b1000_0000) == 0b1000_0000
end