Class: Shellissimo::DSL::CommandParamBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/shellissimo/dsl/command_param_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CommandParamBuilder

Returns a new instance of CommandParamBuilder.



10
11
12
13
14
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 10

def initialize(name)
  @name = name
  @validator = CommandParamValidator.noop
  @kind = :optional
end

Instance Attribute Details

#description(desc) ⇒ Object (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 8

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 8

def name
  @name
end

Instance Method Details

#mandatory!Object



27
28
29
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 27

def mandatory!
  @kind = :mandatory
end

#optional!Object



34
35
36
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 34

def optional!
  @kind = :optional
end

#resultObject



38
39
40
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 38

def result
  CommandParam.new(@name, validator, @description)
end

#validate(description = "", &block) ⇒ Object



20
21
22
# File 'lib/shellissimo/dsl/command_param_builder.rb', line 20

def validate(description = "", &block)
  @validator = @validator & CommandParamValidator.new(description, &block)
end