Method: EpubBook#initialize

Defined in:
lib/epub_book.rb

#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,options={})
  raise '无效的文件' unless File.exists?(filename)
  @title = options[:title]
  @author = options[:author]
  @publisher = options[:publisher]
  @pubdate= options[:pubdate]
  @isbn = options[: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