Class: AppleMusicLibrary::Century

Inherits:
TrackCollection show all
Defined in:
lib/apple_music_library/century.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(century_name) ⇒ Object



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

def self.find_or_create_for(century_name)
  century_start_year = century_name.to_i - (century_name.to_i % 100)
  century_stop_year = century_start_year + 99
  century_name = "#{century_start_year}'s"

  self.find_or_create(century_name)
end

.reportObject



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

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

.tokenObject



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

def self.token
  :century
end