Class: RJL::Album
- Inherits:
-
Object
- Object
- RJL::Album
- Defined in:
- lib/rjl/album.rb
Overview
Represents an album in Apple’s ‘iTunes’ application.
Instance Attribute Summary collapse
-
#album_artist ⇒ String artist name, String 'Various Artists'
readonly
Album’s artist e.g “Simply Red”.
-
#genre ⇒ String
Album genre e.g “Pop/Rock [Alternative/Indie Rock]”.
-
#title ⇒ String
readonly
Album title e.g “Greatest Hits”.
-
#tracks ⇒ List of Track
readonly
The tracks in the album.
Instance Method Summary collapse
-
#initialize(tracks: []) ⇒ Album
constructor
Creates a new RJL::Album.
-
#protected? ⇒ Boolean
Is the album protected from changes?.
- #to_s ⇒ Object
Constructor Details
#initialize(tracks: []) ⇒ Album
Creates a new RJL::Album. Album properties are derived from the properties of the supplied tracks.
13 14 15 |
# File 'lib/rjl/album.rb', line 13 def initialize( tracks: []) @tracks = tracks end |
Instance Attribute Details
#album_artist ⇒ String artist name, String 'Various Artists' (readonly)
Album’s artist e.g “Simply Red”. Returns ‘Various Artists’ if more than one.
20 21 22 |
# File 'lib/rjl/album.rb', line 20 def album_artist @album_artist end |
#genre ⇒ String
Album genre e.g “Pop/Rock [Alternative/Indie Rock]”
38 39 40 |
# File 'lib/rjl/album.rb', line 38 def genre @genre end |
#title ⇒ String (readonly)
Album title e.g “Greatest Hits”
32 33 34 |
# File 'lib/rjl/album.rb', line 32 def title @title end |
#tracks ⇒ List of Track (readonly)
The tracks in the album
57 58 59 |
# File 'lib/rjl/album.rb', line 57 def tracks @tracks end |
Instance Method Details
#protected? ⇒ Boolean
Is the album protected from changes?
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rjl/album.rb', line 63 def protected? protected = false @tracks.each do |track| if track..include? 'protected' protected = true break end end return protected end |
#to_s ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/rjl/album.rb', line 74 def to_s puts "-"*50 puts "> #{self.album_artist}, '#{self.title}'" @tracks.each do |track| puts " #{track.name}" end puts "="*50 end |