Class: Haml::Exec::Generic

Inherits:
Object show all
Defined in:
lib/haml/exec.rb

Overview

An abstract class that encapsulates the executable code for all three executables.

Direct Known Subclasses

CSS2Sass, HTML2Haml, HamlSass

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Generic

Returns a new instance of Generic.

Parameters:

  • args (Array<String>)

    The command-line arguments



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.message
    exit 1
  end
  exit 0
end

#to_sString

Returns A description of the executable.

Returns:

  • (String)

    A description of the executable



35
36
37
# File 'lib/haml/exec.rb', line 35

def to_s
  @opts.to_s
end