Class: GHtml2Pdf::ArgumentParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ghtml2pdf/argument_parser.rb

Overview

Parses the command line arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ ArgumentParser

Returns a new instance of ArgumentParser.

Raises:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ghtml2pdf/argument_parser.rb', line 14

def initialize(argv)
  setup_banner
  setup_margin_options
  setup_help_message
  parser.parse! argv
  @input, @output, = argv
  raise ArgumentError, "An input filename is required" unless @input

  @output ||= "#{File.basename(@input, ".*")}.pdf"
  raise ArgumentError, "Input and output files cannot be the same" if @input == @output
end

Instance Attribute Details

#bottom_marginObject

Returns the value of attribute bottom_margin.



12
13
14
# File 'lib/ghtml2pdf/argument_parser.rb', line 12

def bottom_margin
  @bottom_margin
end

#inputObject (readonly)

Returns the value of attribute input.



12
13
14
# File 'lib/ghtml2pdf/argument_parser.rb', line 12

def input
  @input
end

#left_marginObject

Returns the value of attribute left_margin.



12
13
14
# File 'lib/ghtml2pdf/argument_parser.rb', line 12

def left_margin
  @left_margin
end

#outputObject (readonly)

Returns the value of attribute output.



12
13
14
# File 'lib/ghtml2pdf/argument_parser.rb', line 12

def output
  @output
end

#right_marginObject

Returns the value of attribute right_margin.



12
13
14
# File 'lib/ghtml2pdf/argument_parser.rb', line 12

def right_margin
  @right_margin
end

#top_marginObject

Returns the value of attribute top_margin.



12
13
14
# File 'lib/ghtml2pdf/argument_parser.rb', line 12

def top_margin
  @top_margin
end