Class: PdfOutlineEditor::Dumper
- Inherits:
-
Object
- Object
- PdfOutlineEditor::Dumper
- Defined in:
- lib/pdf_outline_editor/dumper.rb
Constant Summary collapse
- JavaFile =
java.io.File
- IOException =
java.io.IOException
Instance Attribute Summary collapse
-
#closed ⇒ Object
readonly
Returns the value of attribute closed.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #dump ⇒ Object
-
#initialize(input_pdf_path) ⇒ Dumper
constructor
A new instance of Dumper.
Constructor Details
#initialize(input_pdf_path) ⇒ Dumper
Returns a new instance of Dumper.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pdf_outline_editor/dumper.rb', line 22 def initialize(input_pdf_path) begin @doc = PDDocument.load(JavaFile.new(input_pdf_path)) rescue IOException => e raise Error, e. end @pages = @doc.pages @closed = false end |
Instance Attribute Details
#closed ⇒ Object (readonly)
Returns the value of attribute closed.
20 21 22 |
# File 'lib/pdf_outline_editor/dumper.rb', line 20 def closed @closed end |
Class Method Details
.open(input_pdf_path) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/pdf_outline_editor/dumper.rb', line 10 def self.open(input_pdf_path) dumper = new(input_pdf_path) begin yield dumper ensure dumper.close end end |
Instance Method Details
#close ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pdf_outline_editor/dumper.rb', line 42 def close return if @closed @doc.close @closed = true end |
#dump ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/pdf_outline_editor/dumper.rb', line 34 def dump root_outline = @doc.document_catalog.document_outline return unless root_outline traverse(root_outline) end |