Class: PDF::Burst

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/burst.rb,
lib/pdf/burst/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Instance Method Summary collapse

Constructor Details

#initialize(pdf_path, options = {}) ⇒ Burst

Returns a new instance of Burst.



3
4
5
6
7
8
# File 'lib/pdf/burst.rb', line 3

def initialize(pdf_path, options={})
  @pdf_path = pdf_path
  @output_path = options[:output] || "."
  @page_name = options[:filename] || "page_%d"
  @thumbnail_size = options[:thumbnail]
end

Instance Method Details

#generate_thumbnail?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/pdf/burst.rb', line 22

def generate_thumbnail?
  !!@thumbnail_size
end

#page_countObject



18
19
20
# File 'lib/pdf/burst.rb', line 18

def page_count
  `#{page_count_command}`.to_i
end

#run!Object



10
11
12
13
14
15
16
# File 'lib/pdf/burst.rb', line 10

def run!
  page_count.times do |i|
    page_number = i + 1
    system burst_command(page_number)
    system thumbnail_command(page_number) if generate_thumbnail?
  end
end