Module: Id3Taginator::Frames::CountFrames

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

#play_counterInteger?

extracts the play count (PCNT/CNT)

Returns:

  • (Integer, nil)

    returns counter



11
12
13
# File 'lib/id3taginator/frames/count_frames.rb', line 11

def play_counter
  find_frame(Count::PlayCounterFrame.frame_id(@major_version, @options))&.counter
end

#play_counter=(counter) ⇒ Object

sets a counter (PCNT/CNT)

Parameters:

  • counter (Integer)

    the counter to set



18
19
20
# File 'lib/id3taginator/frames/count_frames.rb', line 18

def play_counter=(counter)
  set_frame_fields(Count::PlayCounterFrame, [:@counter], counter)
end

#popularityFrames::Count::Entities::Popularimeter?

extracts the popularity (POPM/POP)

Returns:



30
31
32
33
34
35
# File 'lib/id3taginator/frames/count_frames.rb', line 30

def popularity
  frame = find_frame(Count::PopularityFrame.frame_id(@major_version, @options))
  return nil if frame.nil?

  Count::Entities::Popularimeter.new(frame.email, frame.rating, frame.counter)
end

#popularity=(popularity) ⇒ Object

sets a counter (POPM/POP)

Parameters:



40
41
42
43
# File 'lib/id3taginator/frames/count_frames.rb', line 40

def popularity=(popularity)
  set_frame_fields(Count::PopularityFrame, %i[@email @rating @counter],
                   popularity.email, popularity.rating, popularity.counter)
end

#remove_play_counterObject

removes the play counter frame



23
24
25
# File 'lib/id3taginator/frames/count_frames.rb', line 23

def remove_play_counter
  @frames.delete_if { |f| f.frame_id == Count::PlayCounterFrame.frame_id(@major_version, @options) }
end

#remove_popularityObject

removes the popularity frame



46
47
48
# File 'lib/id3taginator/frames/count_frames.rb', line 46

def remove_popularity
  @frames.delete_if { |f| f.frame_id == Count::PopularityFrame.frame_id(@major_version, @options) }
end