Class: NYTBestsellers::Book
- Inherits:
-
Object
- Object
- NYTBestsellers::Book
- Defined in:
- lib/nytimes/book.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
-
#wol ⇒ Object
Returns the value of attribute wol.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(hash = {}) ⇒ Book
Returns a new instance of Book.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nytimes/book.rb', line 6 def initialize(hash = {}) hash.each do |key, value| self.send("#{key}=", value) end @genre = NYTBestsellers::Genre.find_by_name(hash[:genre]) if !wol.empty? || !summary.empty? @genre.books << self @@all << self end end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/nytimes/book.rb', line 3 def @author end |
#genre ⇒ Object
Returns the value of attribute genre.
3 4 5 |
# File 'lib/nytimes/book.rb', line 3 def genre @genre end |
#publisher ⇒ Object
Returns the value of attribute publisher.
3 4 5 |
# File 'lib/nytimes/book.rb', line 3 def publisher @publisher end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/nytimes/book.rb', line 3 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/nytimes/book.rb', line 3 def title @title end |
#wol ⇒ Object
Returns the value of attribute wol.
3 4 5 |
# File 'lib/nytimes/book.rb', line 3 def wol @wol end |
Class Method Details
.all ⇒ Object
17 18 19 |
# File 'lib/nytimes/book.rb', line 17 def self.all @@all end |
.find_by_title(name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/nytimes/book.rb', line 21 def self.find_by_title(name) self.all.find do |book| if name == book.title book end end end |