Class: LTools::Tool::ToolOpts
- Inherits:
-
Object
- Object
- LTools::Tool::ToolOpts
- Defined in:
- lib/core/opts.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ ToolOpts
constructor
A new instance of ToolOpts.
- #on(opt, value, &block) ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ ToolOpts
Returns a new instance of ToolOpts.
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_a ⇒ Object
33 34 35 |
# File 'lib/core/opts.rb', line 33 def to_a @args end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/core/opts.rb', line 25 def to_s to_str end |
#to_str ⇒ Object
29 30 31 |
# File 'lib/core/opts.rb', line 29 def to_str " #{Shellwords.join(@args)} " end |