class Book

this class holds the data for each book require_relative “EbookDealInfo”

Attributes

author[RW]
blurb[RW]
completable[RW]
genre_one[RW]
genre_two[RW]
price[RW]
rates[RW]
rating[RW]
series[RW]
title[RW]

Public Class Methods

all() click to toggle source
# File lib/ebookdealinfo/book.rb, line 26
def self.all #we'll use this to grab the collection, which the goodreads scraper will use
  @@all
end
create(author, title, price, good_scrape=1) click to toggle source
# File lib/ebookdealinfo/book.rb, line 22
def self.create(author, title, price, good_scrape=1) #deals scrape will pass in hash with title, author, and price
  self.new(author, title, price, good_scrape)
end
new(author, title, price, good_scrape=1) click to toggle source
# File lib/ebookdealinfo/book.rb, line 8
def initialize(author, title, price, good_scrape=1)
  if good_scrape == 1
    @@all << self #push new books
    @author = author
    @title = title
    @price = price
    @completable = true
    InfoScraper.new.info_scrape(self)
  else
    @@all << self
    @completable = false
  end
end

Public Instance Methods

wrap_blurb(width=78) click to toggle source
# File lib/ebookdealinfo/book.rb, line 30
def wrap_blurb(width=78) #code from other projects to make blurbs line wrap; handle unicode replacement elsewhere
lines = []
line = ""
@blurb.split(/\s+/).each do |word|
  if line.size + word.size >= width
    lines << line
    line = word
  elsif line.empty?
    line = word
  else
    line << " " << word
  end
end
lines << line if line
return (lines.join "\n")
end