Class: CmdOpt

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#confObject (readonly)

Returns the value of attribute conf.



36
37
38
# File 'lib/nub/cmds.rb', line 36

def conf
  @conf
end

#descObject (readonly)

Returns the value of attribute desc.



38
39
40
# File 'lib/nub/cmds.rb', line 38

def desc
  @desc
end

#keyObject (readonly)

Returns the value of attribute key.



35
36
37
# File 'lib/nub/cmds.rb', line 35

def key
  @key
end

#requiredObject (readonly)

Returns the value of attribute required.



39
40
41
# File 'lib/nub/cmds.rb', line 39

def required
  @required
end

#typeObject (readonly)

Returns the value of attribute type.



37
38
39
# File 'lib/nub/cmds.rb', line 37

def type
  @type
end