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.
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_a ⇒ Object
32 33 34 |
# File 'lib/core/opts.rb', line 32 def to_a @args end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/core/opts.rb', line 24 def to_s to_str end |
#to_str ⇒ Object
28 29 30 |
# File 'lib/core/opts.rb', line 28 def to_str " #{Shellwords.join(@args)} " end |