forked from George7h/Catalog-of-my-things
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request George7h#44 from George7h/features-create-music-la…
…bel-class Create Music and Genre class
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require './classes/item' | ||
|
||
class Genre < Item | ||
attr_accessor :name | ||
attr_reader :id, :items | ||
|
||
def initialize(name, id = nil) | ||
super | ||
@id = id || Random.random(1..1000) | ||
@name = name | ||
@items = [] | ||
end | ||
|
||
def add_item(item) | ||
@items << item | ||
item.label = self | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require './classes/item' | ||
|
||
class MusicAlbum < Item | ||
attr_accessor :on_spotify | ||
|
||
def initialize(genre, author, source, label, publish_date, on_spotify) | ||
super(genre, author, source, label, publish_date) | ||
@on_spotify = on_spotify | ||
end | ||
|
||
def can_be_archived? | ||
super || @on_spotify | ||
end | ||
end |