Class: Kerplutz::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/kerplutz/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#baseObject (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 banner=(banner)
  base.banner = banner
end

#command(name, desc) {|builder = Builder.new(command)| ... } ⇒ Object

Yields:



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

#nameObject



12
13
14
# File 'lib/kerplutz/builder.rb', line 12

def name
  base.name
end

#resultObject



38
39
40
# File 'lib/kerplutz/builder.rb', line 38

def result
  base
end

#switch(name, desc, opts = {}) ⇒ Object



24
25
26
# File 'lib/kerplutz/builder.rb', line 24

def switch(name, desc, opts={})
  base.add_option(Switch.build(name, desc, opts))
end