class Book
Attributes
episode[RW]
genre[RW]
synopsis[RW]
title[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/podcast_book_club/book.rb, line 32 def self.all @@all end
find_by_keyword(keyword)
click to toggle source
# File lib/podcast_book_club/book.rb, line 64 def self.find_by_keyword(keyword) self.all.select { |book| book.title.downcase.include?(keyword) || book.synopsis.downcase.include?(keyword) unless book.synopsis == nil } end
new(attributes)
click to toggle source
# File lib/podcast_book_club/book.rb, line 11 def initialize(attributes) @episode = [] attributes.each do |k,v| unless v == nil if "#{k}" == "genre" self.add_genre(v) elsif "#{k}" == "episode" self.add_episode(v) elsif "#{k}" == "author" self.add_author(v) else self.send("#{k}=", v) end end end end
Public Instance Methods
add_episode(episode)
click to toggle source
# File lib/podcast_book_club/book.rb, line 36 def add_episode(episode) episode.add_book(self) end
add_genre(genre)
click to toggle source
# File lib/podcast_book_club/book.rb, line 57 def add_genre(genre) @genre ||= [] new_genre = Genre.find_or_create_by_name(genre) new_genre.add_book(self) end