Class: EpubTools::XHTMLExtractor
- Inherits:
-
Object
- Object
- EpubTools::XHTMLExtractor
- Includes:
- Loggable
- Defined in:
- lib/epub_tools/xhtml_extractor.rb
Overview
Extracts text .xhtml files from EPUB archives, excluding nav.xhtml
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ XHTMLExtractor
constructor
Initializes the class.
-
#run ⇒ Array<String>
Runs the extraction process.
Methods included from Loggable
Constructor Details
#initialize(options = {}) ⇒ XHTMLExtractor
Initializes the class
14 15 16 17 18 19 |
# File 'lib/epub_tools/xhtml_extractor.rb', line 14 def initialize( = {}) @source_dir = File.(.fetch(:source_dir)) @target_dir = File.(.fetch(:target_dir)) @verbose = [:verbose] || false FileUtils.mkdir_p(@target_dir) end |
Instance Method Details
#run ⇒ Array<String>
Runs the extraction process
23 24 25 26 27 28 29 30 |
# File 'lib/epub_tools/xhtml_extractor.rb', line 23 def run all_extracted_files = [] epub_files.each do |epub_path| extracted = extract_xhtmls_from(epub_path) all_extracted_files.concat(extracted) if extracted end all_extracted_files end |