Class: Labels::Exec
- Inherits:
-
Object
- Object
- Labels::Exec
- Defined in:
- lib/labels/exec.rb
Overview
This class is the main handler for the command line tool interface. It takes command line arguments and options and renders a barcode using those options.
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Array of command line arguments.
-
#options ⇒ Object
readonly
Hash of parsed options.
-
#parser ⇒ Object
readonly
The parser instance.
-
#source ⇒ Object
readonly
The input source.
-
#target ⇒ Object
readonly
The output target.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Exec
constructor
Creates a new instance with given command line arguments and options.
-
#run ⇒ Object
Runs the command and renders label.
Constructor Details
#initialize(argv) ⇒ Exec
Creates a new instance with given command line arguments and options
35 36 37 38 39 40 |
# File 'lib/labels/exec.rb', line 35 def initialize(argv) @argv = argv @options = {} self._init_parser self._parse! end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Array of command line arguments
20 21 22 |
# File 'lib/labels/exec.rb', line 20 def argv @argv end |
#options ⇒ Object (readonly)
Hash of parsed options
26 27 28 |
# File 'lib/labels/exec.rb', line 26 def @options end |
#parser ⇒ Object (readonly)
The parser instance
23 24 25 |
# File 'lib/labels/exec.rb', line 23 def parser @parser end |
#source ⇒ Object (readonly)
The input source
29 30 31 |
# File 'lib/labels/exec.rb', line 29 def source @source end |
#target ⇒ Object (readonly)
The output target
32 33 34 |
# File 'lib/labels/exec.rb', line 32 def target @target end |
Instance Method Details
#run ⇒ Object
Runs the command and renders label
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/labels/exec.rb', line 43 def run begin document = Labels.open(self.source) unless document.nil? unless self.target.nil? document.render(self.target) else puts document.render end end rescue Exception => e puts e. end end |