Class: Haml::Exec::Generic
Overview
An abstract class that encapsulates the executable code for all three executables.
Instance Method Summary collapse
-
#initialize(args) ⇒ Generic
constructor
A new instance of Generic.
-
#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.
10 11 12 13 |
# File 'lib/haml/exec.rb', line 10 def initialize(args) @args = args @options = {} end |
Instance Method Details
#parse! ⇒ Object
Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/haml/exec.rb', line 17 def parse! begin @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) process_result @options rescue Exception => e raise e if @options[:trace] || e.is_a?(SystemExit) $stderr.puts e. exit 1 end exit 0 end |
#to_s ⇒ String
Returns A description of the executable.
35 36 37 |
# File 'lib/haml/exec.rb', line 35 def to_s @opts.to_s end |