Class: CmdOpt
- Inherits:
-
Object
- Object
- CmdOpt
- Defined in:
- lib/nub/cmds.rb
Overview
Command option class provides a way to encapsulate a command with any additional properties.
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(conf, desc, type: nil, required: false) ⇒ CmdOpt
constructor
A new instance of CmdOpt.
Constructor Details
#initialize(conf, desc, type: nil, required: false) ⇒ CmdOpt
Returns a new instance of CmdOpt.
40 41 42 43 44 45 46 |
# File 'lib/nub/cmds.rb', line 40 def initialize(conf, desc, type:nil, required:false) @conf = conf.gsub(' ', '=') @key = conf.gsub('-', '').split('=').first.to_sym @type = type @desc = desc @required = required end |
Instance Attribute Details
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
36 37 38 |
# File 'lib/nub/cmds.rb', line 36 def conf @conf end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
38 39 40 |
# File 'lib/nub/cmds.rb', line 38 def desc @desc end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
35 36 37 |
# File 'lib/nub/cmds.rb', line 35 def key @key end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
39 40 41 |
# File 'lib/nub/cmds.rb', line 39 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
37 38 39 |
# File 'lib/nub/cmds.rb', line 37 def type @type end |