Class: AppleMusicLibrary::Decade

Inherits:
TrackCollection show all
Defined in:
lib/apple_music_library/decade.rb

Instance Attribute Summary

Attributes inherited from TrackCollection

#name, #tracks

Class Method Summary collapse

Methods inherited from TrackCollection

#add_track, #album_count, all, find_by_name, find_or_create, #initialize, #star_rating, #track_count

Constructor Details

This class inherits a constructor from AppleMusicLibrary::TrackCollection

Class Method Details

.find_or_create_for(year_name) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/apple_music_library/decade.rb', line 12

def self.find_or_create_for(year_name)
  decade_start_year = year_name.to_i - (year_name.to_i % 10)
  decade_stop_year = decade_start_year + 9
  decade_name = "#{decade_start_year}-#{decade_stop_year}"

  self.find_or_create(decade_name)
end

.reportObject



6
7
8
9
10
# File 'lib/apple_music_library/decade.rb', line 6

def self.report
  self.all.sort_by{|d| d.name}.each do |decade|
    puts "#{decade.name} - #{decade.track_count} tracks on #{decade.album_count} albums"
  end
end

.tokenObject



20
21
22
# File 'lib/apple_music_library/decade.rb', line 20

def self.token
  :decade
end