Class: PdfOutlineEditor::Commands::DumpCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_outline_editor/commands/dump_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ DumpCommand

Returns a new instance of DumpCommand.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pdf_outline_editor/commands/dump_command.rb', line 10

def initialize(argv)
  @parser = nil

  @output_formats = i[json yaml]
  @output_format = :json

  @input_pdf_path = nil

  parser.parse!(argv)

  handle_args(argv)
end

Instance Attribute Details

#input_pdf_pathObject (readonly)

Returns the value of attribute input_pdf_path.



8
9
10
# File 'lib/pdf_outline_editor/commands/dump_command.rb', line 8

def input_pdf_path
  @input_pdf_path
end

#output_formatObject (readonly)

Returns the value of attribute output_format.



8
9
10
# File 'lib/pdf_outline_editor/commands/dump_command.rb', line 8

def output_format
  @output_format
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
# File 'lib/pdf_outline_editor/commands/dump_command.rb', line 23

def run
  Dumper.open(@input_pdf_path) do |dumper|
    outlines = dumper.dump

    puts send("convert_to_#{@output_format}", outlines) if outlines
  end
end