Class: GGem::CLI::CLIRB::Option
- Inherits:
-
Object
- Object
- GGem::CLI::CLIRB::Option
- Defined in:
- lib/ggem/cli/clirb.rb
Instance Attribute Summary collapse
-
#abbrev ⇒ Object
readonly
Returns the value of attribute abbrev.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opt_name ⇒ Object
readonly
Returns the value of attribute opt_name.
-
#parser_args ⇒ Object
readonly
Returns the value of attribute parser_args.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, *args) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(name, *args) ⇒ Option
Returns a new instance of Option.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ggem/cli/clirb.rb', line 36 def initialize(name, *args) settings, @desc = args.last.kind_of?(::Hash) ? args.pop : {}, args.pop || '' @name, @opt_name, @abbrev = parse_name_values(name, settings[:abbrev]) @value, @klass = gvalinfo(settings[:value]) @parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass) ["-#{@abbrev}", "--[no-]#{@opt_name}", @desc] else ["-#{@abbrev}", "--#{@opt_name} #{@opt_name.upcase}", @klass, @desc] end end |
Instance Attribute Details
#abbrev ⇒ Object (readonly)
Returns the value of attribute abbrev.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def abbrev @abbrev end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def desc @desc end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def name @name end |
#opt_name ⇒ Object (readonly)
Returns the value of attribute opt_name.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def opt_name @opt_name end |
#parser_args ⇒ Object (readonly)
Returns the value of attribute parser_args.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def parser_args @parser_args end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
34 35 36 |
# File 'lib/ggem/cli/clirb.rb', line 34 def value @value end |