Module: BestSellingBooks::Collectable

Included in:
Amazon, BarnesAndNoble
Defined in:
lib/best_selling_books/collectable.rb

Instance Method Summary collapse

Instance Method Details

#create_and_collect_booksObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/best_selling_books/collectable.rb', line 5

def create_and_collect_books
  self::Scraper.scrape_book_list.each do |hash|
    instance = BestSellingBooks::Books.new
    instance.title = hash[:Title]
    instance.author = hash[:Author]
    instance.author_bio = hash[:Author_Bio]
    instance.price = hash[:Price]
    instance.format = hash[:Format]
    instance.rating = hash[:Rating]
    instance.link = hash[:Link]
    instance.rank = hash[:Rank]
    self.all_books << instance
  end
end

#list_best_sellersObject



20
21
22
23
# File 'lib/best_selling_books/collectable.rb', line 20

def list_best_sellers
  puts self.name + "'s Top 20"
  self.all_books.each {|instance| puts "#{instance.rank}. #{instance.title} by #{instance.author}"}
end