Class: Option

Inherits:
Object
  • Object
show all
Defined in:
lib/hiptest-publisher/options_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short, long, default, type, help, attribute) ⇒ Option

Returns a new instance of Option.



24
25
26
27
28
29
30
31
# File 'lib/hiptest-publisher/options_parser.rb', line 24

def initialize(short, long, default, type, help, attribute)
  @short = short
  @long = long
  @default = default
  @type = type
  @help = help
  @attribute = attribute
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



22
23
24
# File 'lib/hiptest-publisher/options_parser.rb', line 22

def attribute
  @attribute
end

#defaultObject (readonly)

Returns the value of attribute default.



22
23
24
# File 'lib/hiptest-publisher/options_parser.rb', line 22

def default
  @default
end

#helpObject (readonly)

Returns the value of attribute help.



22
23
24
# File 'lib/hiptest-publisher/options_parser.rb', line 22

def help
  @help
end

#longObject (readonly)

Returns the value of attribute long.



22
23
24
# File 'lib/hiptest-publisher/options_parser.rb', line 22

def long
  @long
end

#shortObject (readonly)

Returns the value of attribute short.



22
23
24
# File 'lib/hiptest-publisher/options_parser.rb', line 22

def short
  @short
end

#typeObject (readonly)

Returns the value of attribute type.



22
23
24
# File 'lib/hiptest-publisher/options_parser.rb', line 22

def type
  @type
end

Instance Method Details

#register(opts, options) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hiptest-publisher/options_parser.rb', line 41

def register(opts, options)
  options[attribute] = @default unless default.nil?
  on_values = [
    @short ? "-#{@short}" : nil,
    "--#{@long}",
    @type,
    help
  ].compact

  opts.on(*on_values) do |value|
    options[attribute] = value
    options.__cli_args << attribute
  end
end