Module: Id3Taginator::Frames::EncryptionFrames

Includes:
Frameable
Included in:
Id3v2Tag
Defined in:
lib/id3taginator/frames/encryption_frames.rb

Instance Method Summary collapse

Methods included from Frameable

#find_frame, #find_frames, #set_frame_fields, #set_frame_fields_by_selector, #unsupported_frame

Instance Method Details

#audio_encryptionsArray<Frames::Encryption::Entities::AudioEncryption>

extracts the audio encryptions (AENC/CRA)

Returns:



11
12
13
14
15
16
17
18
# File 'lib/id3taginator/frames/encryption_frames.rb', line 11

def audio_encryptions
  frame = find_frames(Encryption::AudioEncryptionFrame.frame_id(@major_version, @options))
  return [] if frame.nil? || frame.empty?

  frame.map do |f|
    Encryption::Entities::AudioEncryption.new(f.owner_id, f.preview_start, f.preview_length, f.encryption_info)
  end
end

#audio_encryptions=(enc) ⇒ Object Also known as: add_audio_encryption

adds an audio encryption. (AENC/CRA) Multiple ones can be added, as long as they have different owner_ids

Parameters:



24
25
26
27
28
29
# File 'lib/id3taginator/frames/encryption_frames.rb', line 24

def audio_encryptions=(enc)
  set_frame_fields_by_selector(Encryption::AudioEncryptionFrame,
                               %i[@preview_start @preview_length @encryption_info],
                               ->(f) { f.owner_id == enc.owner_id },
                               enc.owner_id, enc.preview_start, enc.preview_length, enc.encryption_info)
end

#encryption_methodsArray<Frames::Encryption::Entities::EncryptionMethod>

extracts the encryption methods (ENCR)

Returns:



45
46
47
48
49
50
51
52
# File 'lib/id3taginator/frames/encryption_frames.rb', line 45

def encryption_methods
  frame = find_frames(Encryption::EncryptionMethodFrame.frame_id(@major_version, @options))
  return [] if frame.nil? || frame.empty?

  frame.map do |f|
    Encryption::Entities::EncryptionMethod.new(f.owner_id, f.method_symbol, f.encryption_data)
  end
end

#encryption_methods=(enc) ⇒ Object Also known as: add_encryption_method

adds an encryption method. (ENCR) Multiple ones can be added, as long as they have different owner_ids

Parameters:



58
59
60
61
62
63
# File 'lib/id3taginator/frames/encryption_frames.rb', line 58

def encryption_methods=(enc)
  set_frame_fields_by_selector(Encryption::EncryptionMethodFrame,
                               %i[@owner_id @method_symbol @encryption_data],
                               ->(f) { f.owner_id == enc.owner_id },
                               enc.owner_id, enc.method_symbol, enc.encryption_data)
end

#remove_audio_encryption(owner_id) ⇒ Object

removes an audio encryption for the specific owner_id (AENC/CRA)

Parameters:

  • owner_id (String)

    the owner_id



36
37
38
39
40
# File 'lib/id3taginator/frames/encryption_frames.rb', line 36

def remove_audio_encryption(owner_id)
  @frames.delete_if do |f|
    f.frame_id == Encryption::AudioEncryptionFrame.frame_id(@major_version, @options) && f.owner_id == owner_id
  end
end

#remove_encryption_method(owner_id) ⇒ Object

removes an encryption method for the specific owner_id (ENCR)

Parameters:

  • owner_id (String)

    the owner_id



70
71
72
73
74
# File 'lib/id3taginator/frames/encryption_frames.rb', line 70

def remove_encryption_method(owner_id)
  @frames.delete_if do |f|
    f.frame_id == Encryption::EncryptionMethodFrame.frame_id(@major_version, @options) && f.owner_id == owner_id
  end
end