Class: AnnotationSecurity::Exec::Generic
- Defined in:
- lib/annotation_security/exec.rb
Overview
An abstract class that encapsulates the executable code for all executables.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(args) ⇒ Generic
constructor
A new instance of Generic.
-
#options ⇒ Object
Parsed options.
-
#parse! ⇒ Object
Parses the command-line arguments and runs the executable.
-
#to_s ⇒ String
A description of the executable.
Constructor Details
#initialize(args) ⇒ Generic
Returns a new instance of Generic.
21 22 23 |
# File 'lib/annotation_security/exec.rb', line 21 def initialize(args) @args = args end |
Instance Method Details
#options ⇒ Object
Parsed options
16 17 18 |
# File 'lib/annotation_security/exec.rb', line 16 def @options ||= {} end |
#parse! ⇒ Object
Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/annotation_security/exec.rb', line 27 def parse! begin @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) process_result rescue Exception => e raise e if e.is_a?(SystemExit) || [:trace] $stderr.puts e. exit 1 end exit 0 end |
#to_s ⇒ String
Returns A description of the executable.
45 46 47 |
# File 'lib/annotation_security/exec.rb', line 45 def to_s @opts.to_s end |