class Genre

Attributes

books[RW]
name[RW]

Public Class Methods

all() click to toggle source
# File lib/podcast_book_club/genre.rb, line 18
def self.all
  @@all
end
new(attributes) click to toggle source
# File lib/podcast_book_club/genre.rb, line 12
def initialize(attributes)
  @books = []
  @name = attributes[:name]
  @books << attributes[:book] if attributes[:book]
end

Public Instance Methods

add_book(book) click to toggle source
# File lib/podcast_book_club/genre.rb, line 22
def add_book(book)
    self.books << book unless self.books.include?(book)
    book.genre << self unless book.genre.include?(self)
    books
end
authors() click to toggle source
# File lib/podcast_book_club/genre.rb, line 28
def authors
  @books.map { |book| book.author }.flatten.uniq
end