Class: Assert::CLIRB::Option

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, desc = nil, abbrev: nil, value: nil) ⇒ Option

Returns a new instance of Option.


34
35
36
37
38
39
40
41
42
43
# File 'lib/assert/clirb.rb', line 34

def initialize(name, desc = nil, abbrev: nil, value: nil)
  @name, @desc = name, desc || ""
  @opt_name, @abbrev = parse_name_values(name, abbrev)
  @value, @klass = gvalinfo(value)
  @parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
    ["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
  else
    ["-#{@abbrev}", "--#{@opt_name} VALUE", @klass, @desc]
  end
end

Instance Attribute Details

#abbrevObject (readonly)

Returns the value of attribute abbrev.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def abbrev
  @abbrev
end

#descObject (readonly)

Returns the value of attribute desc.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def desc
  @desc
end

#klassObject (readonly)

Returns the value of attribute klass.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def name
  @name
end

#opt_nameObject (readonly)

Returns the value of attribute opt_name.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def opt_name
  @opt_name
end

#parser_argsObject (readonly)

Returns the value of attribute parser_args.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def parser_args
  @parser_args
end

#valueObject (readonly)

Returns the value of attribute value.


32
33
34
# File 'lib/assert/clirb.rb', line 32

def value
  @value
end