Class: BookDeals::Book

Inherits:
Object
  • Object
show all
Defined in:
lib/book_deals/book.rb

Overview

book on the deal

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deal, title, author, purchase_url, description = nil) ⇒ Book

Returns a new instance of Book.



7
8
9
10
11
12
13
14
# File 'lib/book_deals/book.rb', line 7

def initialize(deal, title, author, purchase_url, description = nil)
  self.title = title
  self.author = author
  self.purchase_url = purchase_url
  self.description = description
  self.categories = []
  self.deal = deal
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



5
6
7
# File 'lib/book_deals/book.rb', line 5

def author
  @author
end

#categoriesObject

Returns the value of attribute categories.



5
6
7
# File 'lib/book_deals/book.rb', line 5

def categories
  @categories
end

#dealObject

Returns the value of attribute deal.



5
6
7
# File 'lib/book_deals/book.rb', line 5

def deal
  @deal
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/book_deals/book.rb', line 5

def description
  @description
end

#purchase_urlObject

Returns the value of attribute purchase_url.



5
6
7
# File 'lib/book_deals/book.rb', line 5

def purchase_url
  @purchase_url
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/book_deals/book.rb', line 5

def title
  @title
end

Instance Method Details

#to_sObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/book_deals/book.rb', line 16

def to_s
  <<-DETAILS.gsub /^ */, ''
  #{"Book Title:".colorize(:yellow)} #{self.title} \n
  #{"Author:".colorize(:yellow)}  #{self.author} \n
  #{"Description:".colorize(:yellow)} #{self.description} \n
  #{"Deal Price:".colorize(:yellow)} #{self.deal.price} \n
  #{"Original Price:".colorize(:yellow)} #{self.deal.original_price} \n
  #{"Expires in:".colorize(:yellow)} #{self.deal.expires_in} \n
  #{"This book can be purchased on:".colorize(:yellow)} #{self.purchase_url.colorize(:magenta)} \n
  ==============================================================================
  DETAILS
end