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:



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

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

Class Method Details

.build(&block) ⇒ Object



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

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

Instance Method Details

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



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

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



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

def to_a
	@args
end

#to_sObject



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

def to_s
     to_str
end

#to_strObject



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

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