Class: EZML::Exec::Generic
Overview
An abstract class that encapsulates the executable code for all three executables.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(args) ⇒ Generic
constructor
A new instance of Generic.
-
#parse ⇒ Object
Parses the command-line arguments and runs the executable.
-
#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.
12 13 14 15 |
# File 'lib/ezml/exec.rb', line 12 def initialize(args) @args = args = {:for_engine => {}} end |
Instance Method Details
#parse ⇒ Object
Parses the command-line arguments and runs the executable. This does not handle exceptions or exit the program.
39 40 41 42 43 44 45 46 |
# File 'lib/ezml/exec.rb', line 39 def parse @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) process_result end |
#parse! ⇒ Object
Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ezml/exec.rb', line 21 def parse! begin parse rescue Exception => e raise e if [:trace] || e.is_a?(SystemExit) $stderr.print "#{e.class}: " unless e.class == RuntimeError $stderr.puts "#{e.message}" $stderr.puts " Use --trace for backtrace." exit 1 end exit 0 end |
#to_s ⇒ String
Returns A description of the executable.
49 50 51 |
# File 'lib/ezml/exec.rb', line 49 def to_s @opts.to_s end |