Class: Episode
- Inherits:
-
Object
- Object
- Episode
- Extended by:
- Findable::ClassMethods, Memorable::ClassMethods, Sortable::ClassMethods
- Includes:
- Memorable::InstanceMethods
- Defined in:
- lib/podcast_book_club/episode.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#books ⇒ Object
Returns the value of attribute books.
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#link ⇒ Object
Returns the value of attribute link.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #add_book(book) ⇒ Object
-
#initialize(attributes) ⇒ Episode
constructor
A new instance of Episode.
Methods included from Memorable::ClassMethods
Methods included from Findable::ClassMethods
find_by_name, find_by_title, find_or_create_by_name, find_or_create_by_title
Methods included from Sortable::ClassMethods
Methods included from Memorable::InstanceMethods
Constructor Details
#initialize(attributes) ⇒ Episode
Returns a new instance of Episode.
12 13 14 15 16 17 18 19 |
# File 'lib/podcast_book_club/episode.rb', line 12 def initialize(attributes) @books = [] attributes.each do |k, v| self.send("#{k}=", v) end end |
Instance Attribute Details
#books ⇒ Object
Returns the value of attribute books.
2 3 4 |
# File 'lib/podcast_book_club/episode.rb', line 2 def books @books end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/podcast_book_club/episode.rb', line 2 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/podcast_book_club/episode.rb', line 2 def description @description end |
#link ⇒ Object
Returns the value of attribute link.
2 3 4 |
# File 'lib/podcast_book_club/episode.rb', line 2 def link @link end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/podcast_book_club/episode.rb', line 2 def title @title end |
Class Method Details
.all ⇒ Object
21 22 23 |
# File 'lib/podcast_book_club/episode.rb', line 21 def self.all @@all end |
.find_by_date(first_date, last_date) ⇒ Object
36 37 38 |
# File 'lib/podcast_book_club/episode.rb', line 36 def self.find_by_date(first_date, last_date) self.all.select { |ep| ep.date >= first_date && ep.date <= last_date } end |
.find_by_keyword(keyword) ⇒ Object
31 32 33 |
# File 'lib/podcast_book_club/episode.rb', line 31 def self.find_by_keyword(keyword) self.all.select { |ep| ep.title.downcase.include?(keyword) } end |
Instance Method Details
#add_book(book) ⇒ Object
25 26 27 28 29 |
# File 'lib/podcast_book_club/episode.rb', line 25 def add_book(book) self.books << book unless self.books.include?(book) book.episode << self unless book.episode.include?(self) books end |