Class: Bookscan::Book
- Inherits:
-
Object
- Object
- Bookscan::Book
- Defined in:
- lib/bookscan/book.rb
Instance Attribute Summary collapse
-
#group_url ⇒ Object
Returns the value of attribute group_url.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #book_id ⇒ Object
- #d ⇒ Object
- #filename ⇒ Object
- #hash ⇒ Object
- #isbn ⇒ Object
- #title_short ⇒ Object
- #to_s ⇒ Object
- #tune_type ⇒ Object
- #tune_url ⇒ Object
Instance Attribute Details
#group_url ⇒ Object
Returns the value of attribute group_url.
48 49 50 |
# File 'lib/bookscan/book.rb', line 48 def group_url @group_url end |
#title ⇒ Object
Returns the value of attribute title.
48 49 50 |
# File 'lib/bookscan/book.rb', line 48 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
48 49 50 |
# File 'lib/bookscan/book.rb', line 48 def url @url end |
Instance Method Details
#book_id ⇒ Object
89 90 91 92 93 94 95 96 97 |
# 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 ⇒ Object
52 53 54 |
# File 'lib/bookscan/book.rb', line 52 def d return $1 if /.*download.php\?d=([^&]+)/ =~ @url end |
#filename ⇒ Object
69 70 71 72 73 74 75 |
# 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 ⇒ Object
55 56 57 |
# File 'lib/bookscan/book.rb', line 55 def hash return $1 if /.*bookdetail.php\?hash=(.*)/ =~ @group_url end |
#isbn ⇒ Object
84 85 86 87 |
# 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 ⇒ Object
63 64 65 66 67 |
# File 'lib/bookscan/book.rb', line 63 def title_short @title.sub(/\.pdf$/,""). sub(/_s$/,""). sub(/_[0-9a-zA-Z]+$/,"") end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/bookscan/book.rb', line 59 def to_s @title end |
#tune_type ⇒ Object
77 78 79 80 81 82 |
# File 'lib/bookscan/book.rb', line 77 def tune_type if TUNED_PATTERN =~ title return $2 end nil end |
#tune_url ⇒ Object
49 50 51 |
# File 'lib/bookscan/book.rb', line 49 def tune_url "/bookoptimize.php?hash=%s&d=%s&filename=%s" % [hash,d,URI.encode(@title)] end |