Class: Book
- Inherits:
-
Object
- Object
- Book
- Defined in:
- lib/nyt_bestsellers_cli_gem/book.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#category ⇒ Object
Returns the value of attribute category.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #add_book_to_category(category) ⇒ Object
-
#initialize(title = nil, author = nil, summary = nil, category = nil) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(title = nil, author = nil, summary = nil, category = nil) ⇒ Book
Returns a new instance of Book.
7 8 9 10 11 12 13 14 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 7 def initialize(title = nil, = nil, summary = nil, category = nil) @title = title @author = @summary = summary @category = category @@all << self add_book_to_category(category) end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 3 def @author end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 3 def category @category end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 3 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 3 def title @title end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 20 def self.all @@all end |
.find_by_title(title) ⇒ Object
24 25 26 |
# File 'lib/nyt_bestsellers_cli_gem/book.rb', line 24 def self.find_by_title(title) self.all.detect {|book| book.title == title} end |