Class: Kerplutz::Builder
- Inherits:
-
Object
- Object
- Kerplutz::Builder
- Defined in:
- lib/kerplutz/builder.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Instance Method Summary collapse
- #action(name, desc, opts = {}, &action) ⇒ Object
- #banner=(banner) ⇒ Object
- #command(name, desc) {|builder = Builder.new(command)| ... } ⇒ Object
- #flag(name, desc, opts = {}) ⇒ Object
-
#initialize(base) ⇒ Builder
constructor
A new instance of Builder.
- #name ⇒ Object
- #result ⇒ Object
- #switch(name, desc, opts = {}) ⇒ Object
Constructor Details
#initialize(base) ⇒ Builder
Returns a new instance of Builder.
8 9 10 |
# File 'lib/kerplutz/builder.rb', line 8 def initialize(base) @base = base end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
6 7 8 |
# File 'lib/kerplutz/builder.rb', line 6 def base @base end |
Instance Method Details
#action(name, desc, opts = {}, &action) ⇒ Object
28 29 30 |
# File 'lib/kerplutz/builder.rb', line 28 def action(name, desc, opts={}, &action) base.add_option(Action.build(name, desc, opts, &action)) end |
#banner=(banner) ⇒ Object
16 17 18 |
# File 'lib/kerplutz/builder.rb', line 16 def () base. = end |
#command(name, desc) {|builder = Builder.new(command)| ... } ⇒ Object
32 33 34 35 36 |
# File 'lib/kerplutz/builder.rb', line 32 def command(name, desc) command = Command.new(name, desc, base.arguments) yield builder = Builder.new(command) base.add_command(builder.result) end |
#flag(name, desc, opts = {}) ⇒ Object
20 21 22 |
# File 'lib/kerplutz/builder.rb', line 20 def flag(name, desc, opts={}) base.add_option(Flag.build(name, desc, opts)) end |
#name ⇒ Object
12 13 14 |
# File 'lib/kerplutz/builder.rb', line 12 def name base.name end |
#result ⇒ Object
38 39 40 |
# File 'lib/kerplutz/builder.rb', line 38 def result base end |