Class: PdfOutlineEditor::Commands::InitCommand
- Inherits:
-
Object
- Object
- PdfOutlineEditor::Commands::InitCommand
- Defined in:
- lib/pdf_outline_editor/commands/init_command.rb
Instance Attribute Summary collapse
-
#output_format ⇒ Object
readonly
Returns the value of attribute output_format.
Instance Method Summary collapse
-
#initialize(argv) ⇒ InitCommand
constructor
A new instance of InitCommand.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ InitCommand
Returns a new instance of InitCommand.
10 11 12 13 14 15 16 17 |
# File 'lib/pdf_outline_editor/commands/init_command.rb', line 10 def initialize(argv) @parser = nil @output_formats = %i[json yaml] @output_format = :json parser.parse!(argv) end |
Instance Attribute Details
#output_format ⇒ Object (readonly)
Returns the value of attribute output_format.
8 9 10 |
# File 'lib/pdf_outline_editor/commands/init_command.rb', line 8 def output_format @output_format end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pdf_outline_editor/commands/init_command.rb', line 19 def run sample_outlines = [ { 'title' => 'Chapter 1', 'page' => 1, 'children' => [ { 'title' => 'Section 1.1', 'page' => 2 } ] }, { 'title' => 'Chapter 2', 'page' => 3 } ] puts send("convert_to_#{@output_format}", sample_outlines) end |