Class: BookwormBuddy::Book
- Inherits:
-
Object
- Object
- BookwormBuddy::Book
- Defined in:
- lib/bookworm_buddy/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.
-
#description_url ⇒ Object
Returns the value of attribute description_url.
-
#price ⇒ Object
Returns the value of attribute price.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .create(book_array) ⇒ Object
- .empty ⇒ Object
- .list_books_by_category(category_number) ⇒ Object
- .list_description(description) ⇒ Object
- .list_title(book) ⇒ Object
Instance Method Summary collapse
-
#initialize(bestseller_hash) ⇒ Book
constructor
A new instance of Book.
Constructor Details
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/bookworm_buddy/book.rb', line 2 def @author end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/bookworm_buddy/book.rb', line 2 def description @description end |
#description_url ⇒ Object
Returns the value of attribute description_url.
2 3 4 |
# File 'lib/bookworm_buddy/book.rb', line 2 def description_url @description_url end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/bookworm_buddy/book.rb', line 2 def price @price end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/bookworm_buddy/book.rb', line 2 def title @title end |
Class Method Details
.create(book_array) ⇒ Object
10 11 12 |
# File 'lib/bookworm_buddy/book.rb', line 10 def self.create(book_array) book_array.each {|book| self.new(book)} end |
.empty ⇒ Object
32 33 34 |
# File 'lib/bookworm_buddy/book.rb', line 32 def self.empty ALL.clear end |
.list_books_by_category(category_number) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/bookworm_buddy/book.rb', line 14 def self.list_books_by_category(category_number) puts BookwormBuddy::Category::ALL[category_number.to_i - 1].name.colorize(:magenta) if ALL == [] puts "\n""So sorry, that category seems to be empty at the moment. Check back soon!".colorize(:red) BookwormBuddy::CLI.new. else ALL.each_with_index {|book, index| puts "#{index+1}. \"#{book.title}\" - by: #{book.} - #{book.price}"} end end |
.list_description(description) ⇒ Object
28 29 30 |
# File 'lib/bookworm_buddy/book.rb', line 28 def self.list_description(description) puts "#{description}" end |
.list_title(book) ⇒ Object
24 25 26 |
# File 'lib/bookworm_buddy/book.rb', line 24 def self.list_title(book) puts "'#{book.title}'".colorize(:magenta) end |