Class: Assert::CLIRB::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/assert/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *args) ⇒ Option

Returns a new instance of Option.


124
125
126
127
128
129
130
131
132
133
# File 'lib/assert/cli.rb', line 124

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

#abbrevObject (readonly)

Returns the value of attribute abbrev


122
123
124
# File 'lib/assert/cli.rb', line 122

def abbrev
  @abbrev
end

#descObject (readonly)

Returns the value of attribute desc


122
123
124
# File 'lib/assert/cli.rb', line 122

def desc
  @desc
end

#klassObject (readonly)

Returns the value of attribute klass


122
123
124
# File 'lib/assert/cli.rb', line 122

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name


122
123
124
# File 'lib/assert/cli.rb', line 122

def name
  @name
end

#opt_nameObject (readonly)

Returns the value of attribute opt_name


122
123
124
# File 'lib/assert/cli.rb', line 122

def opt_name
  @opt_name
end

#parser_argsObject (readonly)

Returns the value of attribute parser_args


122
123
124
# File 'lib/assert/cli.rb', line 122

def parser_args
  @parser_args
end

#valueObject (readonly)

Returns the value of attribute value


122
123
124
# File 'lib/assert/cli.rb', line 122

def value
  @value
end