Class: BestReads::Book
- Inherits:
-
Object
- Object
- BestReads::Book
- Defined in:
- lib/best_reads/book.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#display ⇒ Object
readonly
Returns the value of attribute display.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/best_reads/book.rb', line 2 def @author end |
#display ⇒ Object (readonly)
Returns the value of attribute display.
3 4 5 |
# File 'lib/best_reads/book.rb', line 3 def display @display end |
#rating ⇒ Object
Returns the value of attribute rating.
2 3 4 |
# File 'lib/best_reads/book.rb', line 2 def @rating end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/best_reads/book.rb', line 2 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/best_reads/book.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
24 25 26 |
# File 'lib/best_reads/book.rb', line 24 def self.all @@all end |
.create_and_display_from_collection(book_hash) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/best_reads/book.rb', line 6 def self.create_and_display_from_collection(book_hash) book_hash.each_with_index do |book, index| new_book = self.new() book.each {|key, value| new_book.send(("#{key}="),value.strip)} new_book.save new_book.display_by_index(index) end end |
Instance Method Details
#display_by_index(index) ⇒ Object
15 16 17 18 |
# File 'lib/best_reads/book.rb', line 15 def display_by_index(index) puts "#{index+1}. #{self.title} by #{self.}" puts "rating: #{self.}" end |
#save ⇒ Object
20 21 22 |
# File 'lib/best_reads/book.rb', line 20 def save self.class.all<<self end |