Class: ComicBook::PDF::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/comic_book/pdf/extractor.rb

Constant Summary collapse

DEFAULT_DPI =
300

Instance Method Summary collapse

Constructor Details

#initialize(pdf_path) ⇒ Extractor

Returns a new instance of Extractor.



6
7
8
# File 'lib/comic_book/pdf/extractor.rb', line 6

def initialize pdf_path
  @pdf_path = File.expand_path pdf_path
end

Instance Method Details

#extract(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/comic_book/pdf/extractor.rb', line 10

def extract options = {}
  extension       = options.fetch :extension, :cb
  delete_original = options.fetch :delete_original, false
  @dpi            = options.fetch :dpi, DEFAULT_DPI

  destination = options[:to] || determine_extract_path(extension)
  create_destination_directory destination
  render_pages destination
  cleanup_pdf_file if delete_original

  destination
end