Module: Id3Taginator::Frames::PrivateFrames

Includes:
Frameable
Included in:
Id3v2Tag
Defined in:
lib/id3taginator/frames/private_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

#private_framesArray<Frames::Private::Entities::PrivateFrame>

extracts the private frames (PRIV)

Returns:



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

def private_frames
  frame = find_frames(Private::PrivateFrame.frame_id(@major_version, @options))
  return [] if frame.nil? || frame.empty?

  frame.map { |f| Private::Entities::PrivateFrame.new(f.owner_id, f.private_data) }
end

#private_frames=(priv) ⇒ Object Also known as: add_private_frame

adds a private frame (PRIV) Multiple ones can be added, as long as they have a different owner_id

Parameters:



22
23
24
25
26
# File 'lib/id3taginator/frames/private_frames.rb', line 22

def private_frames=(priv)
  set_frame_fields_by_selector(Private::PrivateFrame, %i[@owner_id @private_data],
                               ->(f) { f.owner_id == priv.owner_id },
                               priv.owner_id, priv.private_data)
end

#remove_private_frame(owner_id) ⇒ Object

removes a pictures for the specific owner_id

Parameters:

  • owner_id (String)

    the owner_id



33
34
35
36
37
# File 'lib/id3taginator/frames/private_frames.rb', line 33

def remove_private_frame(owner_id)
  @frames.delete_if do |f|
    f.frame_id == Private::PrivateFrame.frame_id(@major_version, @options) && f.owner_id == owner_id
  end
end