Class: Shellissimo::DSL::CommandParamBuilder
- Inherits:
-
Object
- Object
- Shellissimo::DSL::CommandParamBuilder
- Defined in:
- lib/shellissimo/dsl/command_param_builder.rb
Instance Attribute Summary collapse
-
#description(desc) ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ CommandParamBuilder
constructor
A new instance of CommandParamBuilder.
- #mandatory! ⇒ Object
- #optional! ⇒ Object
- #result ⇒ Object
- #validate(description = "", &block) ⇒ Object
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 |
#name ⇒ Object (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 |
#result ⇒ Object
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 |