Class: EpubBook
Overview
epub_book
处理EPUB书的类。
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#isbn ⇒ Object
readonly
Returns the value of attribute isbn.
-
#outline ⇒ Object
readonly
Returns the value of attribute outline.
-
#pubdate ⇒ Object
readonly
Returns the value of attribute pubdate.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(filename, options = {}) ⇒ EpubBook
constructor
A new instance of EpubBook.
- #to_doc_book ⇒ Object
- #toc_to_text ⇒ Object
Constructor Details
#initialize(filename, options = {}) ⇒ EpubBook
Returns a new instance of EpubBook.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/epub_book.rb', line 10 def initialize(filename,={}) raise '无效的文件' unless File.exists?(filename) @title = [:title] @author = [:author] @publisher = [:publisher] @pubdate= [:pubdate] @isbn = [:isbn] text = Utils.extract_text_from_file(filename,'.epub') unless Utils.detect_utf8(text) text = Utils.to_utf8(text) end text = preprocess_content(text) @outline, @content = extract_for_epub_text(text) end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def @author end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def content @content end |
#isbn ⇒ Object (readonly)
Returns the value of attribute isbn.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def isbn @isbn end |
#outline ⇒ Object (readonly)
Returns the value of attribute outline.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def outline @outline end |
#pubdate ⇒ Object (readonly)
Returns the value of attribute pubdate.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def pubdate @pubdate end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def publisher @publisher end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/epub_book.rb', line 8 def title @title end |
Instance Method Details
#to_doc_book ⇒ Object
30 31 32 |
# File 'lib/epub_book.rb', line 30 def to_doc_book build_doc_book(@outline,@content,{:title=>title,:publisher=>publisher,:pubdate=>pubdate,:author=>,:isbn=>isbn}) end |
#toc_to_text ⇒ Object
26 27 28 |
# File 'lib/epub_book.rb', line 26 def toc_to_text outline end |