Class: Shellissimo::CommandParam
- Inherits:
-
Object
- Object
- Shellissimo::CommandParam
- Defined in:
- lib/shellissimo/command_param.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
-
#initialize(name, validator = nil, description = "") ⇒ CommandParam
constructor
A new instance of CommandParam.
- #name ⇒ Object
- #valid?(value) ⇒ Boolean
Constructor Details
#initialize(name, validator = nil, description = "") ⇒ CommandParam
Returns a new instance of CommandParam.
8 9 10 11 12 |
# File 'lib/shellissimo/command_param.rb', line 8 def initialize(name, validator = nil, description = "") @name, @description = String(name), String(description) raise ArgumentError, "command param name can't be blank" if @name.empty? @validator = validator || CommandParamValidator.noop end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/shellissimo/command_param.rb', line 6 def description @description end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
6 7 8 |
# File 'lib/shellissimo/command_param.rb', line 6 def validator @validator end |
Instance Method Details
#name ⇒ Object
14 15 16 |
# File 'lib/shellissimo/command_param.rb', line 14 def name @name.to_sym end |
#valid?(value) ⇒ Boolean
18 19 20 |
# File 'lib/shellissimo/command_param.rb', line 18 def valid?(value) !!@validator[value] end |