Skip to content

Commit

Permalink
Add genre class
Browse files Browse the repository at this point in the history
  • Loading branch information
CesarHerr committed Sep 12, 2023
1 parent 16f7769 commit 4bc57fa
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions genre.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative 'item'

class Genre
attr_accessor :name

def initialize(name, id = nil)
@id = id || Random.rand(1..1000)
@name = name
@items = []
end

def add_item(item)
return unless item.is_a?(Item)

@items << item
item.genre = self
end

private

attr_accessor :id, :items
end

0 comments on commit 4bc57fa

Please sign in to comment.