Class: LTools::Tool::ToolOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/core/opts.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ ToolOpts

Returns a new instance of ToolOpts.

Yields:

  • (_self)

Yield Parameters:



9
10
11
12
# File 'lib/core/opts.rb', line 9

def initialize
	@args = []
	yield self if block_given?
end

Class Method Details

.build(&block) ⇒ Object



5
6
7
# File 'lib/core/opts.rb', line 5

def self.build(&block)
  new(&block).to_s
end

Instance Method Details

#on(opt, value, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/core/opts.rb', line 14

def on(opt, value, &block)
	if value
		value = block.call(value) if block
		if value
         @args << opt if opt
         @args << value
		end
	end
end

#to_aObject



32
33
34
# File 'lib/core/opts.rb', line 32

def to_a
	@args
end

#to_sObject



24
25
26
# File 'lib/core/opts.rb', line 24

def to_s
     to_str
end

#to_strObject



28
29
30
# File 'lib/core/opts.rb', line 28

def to_str
				" #{Shellwords.join(@args)} "
end