Class: Album
- Inherits:
-
Object
- Object
- Album
- Defined in:
- lib/best_music/album.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#artist ⇒ Object
Returns the value of attribute artist.
-
#description ⇒ Object
Returns the value of attribute description.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, artist, genre, url) ⇒ Album
constructor
A new instance of Album.
Constructor Details
#initialize(name, artist, genre, url) ⇒ Album
Returns a new instance of Album.
8 9 10 11 12 13 14 15 |
# File 'lib/best_music/album.rb', line 8 def initialize(name, artist, genre, url) @name = name @artist = artist @genre = genre @url = url Genre.all.each {|g| g.albums << self if g.name == genre} self.class.all << self end |
Instance Attribute Details
#artist ⇒ Object
Returns the value of attribute artist.
4 5 6 |
# File 'lib/best_music/album.rb', line 4 def artist @artist end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/best_music/album.rb', line 4 def description @description end |
#genre ⇒ Object
Returns the value of attribute genre.
4 5 6 |
# File 'lib/best_music/album.rb', line 4 def genre @genre end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/best_music/album.rb', line 4 def name @name end |
#rating ⇒ Object
Returns the value of attribute rating.
4 5 6 |
# File 'lib/best_music/album.rb', line 4 def @rating end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/best_music/album.rb', line 4 def url @url end |
Class Method Details
.albums_by_rating ⇒ Object
21 22 23 |
# File 'lib/best_music/album.rb', line 21 def self. all.sort_by {|a| a.}.reverse end |
.all ⇒ Object
17 18 19 |
# File 'lib/best_music/album.rb', line 17 def self.all @@all end |