Class: HTML2TeX::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/html2tex/cli.rb

Constant Summary collapse

CleanExit =
Class.new(RuntimeError)
DirtyExit =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
# File 'lib/html2tex/cli.rb', line 10

def initialize(argv)
  @argv    = argv
  @options = {}
end

Instance Attribute Details

#input_fileObject (readonly)

Returns the value of attribute input_file.



8
9
10
# File 'lib/html2tex/cli.rb', line 8

def input_file
  @input_file
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/html2tex/cli.rb', line 8

def options
  @options
end

#output_fileObject (readonly)

Returns the value of attribute output_file.



8
9
10
# File 'lib/html2tex/cli.rb', line 8

def output_file
  @output_file
end

Instance Method Details

#parseObject



19
20
21
22
23
24
25
26
27
# File 'lib/html2tex/cli.rb', line 19

def parse
  parser.parse!(@argv)

  unless @input_file = @argv[0]
    raise DirtyExit
  end

  @output_file = @argv[1] || @input_file.sub(/\.[^\.]+$|$/, ".tex")
end

#usageObject



15
16
17
# File 'lib/html2tex/cli.rb', line 15

def usage
  parser.to_s
end