class Bookscan::Book

Attributes

group_url[RW]
title[RW]
url[RW]

Public Instance Methods

book_id() click to toggle source
# File lib/bookscan/book.rb, line 89
def book_id
  return isbn if isbn
  title = @title
  if TUNED_PATTERN =~ title
    title = $3
  end
  title.gsub!(/_s\.pdf$/,".pdf")
  Digest::MD5.hexdigest(title).to_s[1,10]
end
d() click to toggle source
# File lib/bookscan/book.rb, line 52
def d
  return $1 if /.*download.php\?d=([^&]+)/ =~ @url
end
filename() click to toggle source
# File lib/bookscan/book.rb, line 69
def filename
  return @title if isbn
  if /(.*)\.pdf$/ =~ @title
    return $1 + "_" + book_id + ".pdf"
  end
  raise "Can't make filename"
end
hash() click to toggle source
# File lib/bookscan/book.rb, line 55
def hash
  return $1 if /.*bookdetail.php\?hash=(.*)/ =~ @group_url
end
isbn() click to toggle source
# File lib/bookscan/book.rb, line 84
def isbn
  return $1 if /_([0-9a-zA-Z]+)_s\.pdf$/ =~ @title
  return $1 if /_([0-9a-zA-Z]+)\.pdf$/ =~ @title
end
title_short() click to toggle source
# File lib/bookscan/book.rb, line 63
def title_short
  @title.sub(/\.pdf$/,"").
    sub(/_s$/,"").
    sub(/_[0-9a-zA-Z]+$/,"")
end
to_s() click to toggle source
# File lib/bookscan/book.rb, line 59
def to_s
  @title
end
tune_type() click to toggle source
# File lib/bookscan/book.rb, line 77
def tune_type
  if TUNED_PATTERN =~ title
    return $2
  end
  nil
end
tune_url() click to toggle source
# File lib/bookscan/book.rb, line 49
def tune_url
  "/bookoptimize.php?hash=%s&d=%s&filename=%s" % [hash,d,URI.encode(@title)]
end