Class: NotableBooks2018::Book
- Inherits:
-
Object
- Object
- NotableBooks2018::Book
- Defined in:
- lib/notable_books_2018/book.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#description ⇒ Object
Returns the value of attribute description.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#price ⇒ Object
Returns the value of attribute price.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(book_hash) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(book_hash) ⇒ Book
Returns a new instance of Book.
12 13 14 15 16 17 |
# File 'lib/notable_books_2018/book.rb', line 12 def initialize(book_hash) book_hash.each do |attribute, value| self.send("#{attribute}=", value) end @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
5 6 7 |
# File 'lib/notable_books_2018/book.rb', line 5 def @author end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/notable_books_2018/book.rb', line 5 def description @description end |
#genre ⇒ Object
Returns the value of attribute genre.
6 7 8 |
# File 'lib/notable_books_2018/book.rb', line 6 def genre @genre end |
#price ⇒ Object
Returns the value of attribute price.
5 6 7 |
# File 'lib/notable_books_2018/book.rb', line 5 def price @price end |
#publisher ⇒ Object
Returns the value of attribute publisher.
5 6 7 |
# File 'lib/notable_books_2018/book.rb', line 5 def publisher @publisher end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/notable_books_2018/book.rb', line 5 def title @title end |
Class Method Details
.all ⇒ Object
8 9 10 |
# File 'lib/notable_books_2018/book.rb', line 8 def self.all @@all end |
.create_from_collection(book_array) ⇒ Object
26 27 28 29 30 |
# File 'lib/notable_books_2018/book.rb', line 26 def self.create_from_collection(book_array) book_array.each do |book_hash| NotableBooks2018::Book.new(book_hash) end end |