Module: Id3Taginator::Frames::GroupingFrames

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

#group_identificationsArray<Frames::Grouping::Entities::GroupIdentification>

extracts the group information (GRID)

Returns:



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

def group_identifications
  frame = find_frames(Grouping::GroupIdentificationFrame.frame_id(@major_version, @options))
  return [] if frame.nil? || frame.empty?

  frame.map do |f|
    Grouping::Entities::GroupIdentification.new(f.owner_id, f.group_symbol, f.group_dependant_data)
  end
end

#group_identifications=(group) ⇒ Object Also known as: add_group_identification

adds a group identification (GRID)

Parameters:



23
24
25
26
27
# File 'lib/id3taginator/frames/grouping_frames.rb', line 23

def group_identifications=(group)
  set_frame_fields_by_selector(Grouping::GroupIdentificationFrame, i[@group_symbol @group_dependant_data],
                               ->(f) { f.owner_id == group.owner_id },
                               group.owner_id, group.group_symbol, group.group_dependant_data)
end

#groupingString?

extracts the Grouping (GRP1)

Returns:

  • (String, nil)

    returns the Grouping information



44
45
46
# File 'lib/id3taginator/frames/grouping_frames.rb', line 44

def grouping
  find_frame(Grouping::GroupingFrame.frame_id(@major_version, @options))&.grouping
end

#grouping=(grouping) ⇒ Object

sets the grouping (GRP1)

Parameters:

  • grouping (String)

    the Grouping



51
52
53
# File 'lib/id3taginator/frames/grouping_frames.rb', line 51

def grouping=(grouping)
  set_frame_fields(Grouping::GroupingFrame, [:@grouping], grouping)
end

#remove_group_identification(owner_id) ⇒ Object

removes a group identification for the specific owner_id

Parameters:

  • owner_id (String)

    the owner_id



34
35
36
37
38
39
# File 'lib/id3taginator/frames/grouping_frames.rb', line 34

def remove_group_identification(owner_id)
  @frames.delete_if do |f|
    f.frame_id == Grouping::GroupIdentificationFrame.frame_id(@major_version, @options) &&
      f.owner_id == owner_id
  end
end

#remove_groupingObject

removes the grouping frame



56
57
58
# File 'lib/id3taginator/frames/grouping_frames.rb', line 56

def remove_grouping
  @frames.delete_if { |f| f.frame_id == Grouping::GroupingFrame.frame_id(@major_version, @options) }
end