Class: AppleMusicLibrary::Album
Constant Summary
collapse
- @@albums =
{}
Instance Attribute Summary collapse
#tracks
Class Method Summary
collapse
Instance Method Summary
collapse
#add_track, #album_count, find_by_name, #star_rating, #track_count
Constructor Details
#initialize(album_name, artist) ⇒ Album
Returns a new instance of Album.
9
10
11
12
|
# File 'lib/apple_music_library/album.rb', line 9
def initialize(album_name, artist)
@artist = artist
super
end
|
Instance Attribute Details
#artist ⇒ Object
Returns the value of attribute artist.
5
6
7
|
# File 'lib/apple_music_library/album.rb', line 5
def artist
@artist
end
|
Class Method Details
.all ⇒ Object
14
15
16
|
# File 'lib/apple_music_library/album.rb', line 14
def self.all
@@albums.values
end
|
.find_or_create(artist, album_name) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/apple_music_library/album.rb', line 18
def self.find_or_create(artist, album_name)
key = "#{artist.name}-#{album_name}"
if @@albums[key]
return @@albums[key]
end
@@albums[key] = self.new(album_name, artist)
end
|
.token ⇒ Object
45
46
47
|
# File 'lib/apple_music_library/album.rb', line 45
def self.token
:album
end
|
Instance Method Details
#dump ⇒ Object
38
39
40
41
42
43
|
# File 'lib/apple_music_library/album.rb', line 38
def dump
puts "#{artist.name} - #{name}"
tracks.each do |track|
puts "\t#{track.name}"
end
end
|
#id ⇒ Object
26
27
28
|
# File 'lib/apple_music_library/album.rb', line 26
def id
"#{artist.name}-#{album_name}"
end
|
#name ⇒ Object
30
31
32
|
# File 'lib/apple_music_library/album.rb', line 30
def name
@album_name
end
|
#year ⇒ Object
34
35
36
|
# File 'lib/apple_music_library/album.rb', line 34
def year
@year ||= @tracks.sort_by(&:year).last.year
end
|