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.



59
60
61
62
63
64
65
66
# File 'lib/hiptest-publisher/options_parser.rb', line 59

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.



57
58
59
# File 'lib/hiptest-publisher/options_parser.rb', line 57

def attribute
  @attribute
end

#defaultObject (readonly)

Returns the value of attribute default.



57
58
59
# File 'lib/hiptest-publisher/options_parser.rb', line 57

def default
  @default
end

#helpObject (readonly)

Returns the value of attribute help.



57
58
59
# File 'lib/hiptest-publisher/options_parser.rb', line 57

def help
  @help
end

#longObject (readonly)

Returns the value of attribute long.



57
58
59
# File 'lib/hiptest-publisher/options_parser.rb', line 57

def long
  @long
end

#shortObject (readonly)

Returns the value of attribute short.



57
58
59
# File 'lib/hiptest-publisher/options_parser.rb', line 57

def short
  @short
end

#typeObject (readonly)

Returns the value of attribute type.



57
58
59
# File 'lib/hiptest-publisher/options_parser.rb', line 57

def type
  @type
end

Instance Method Details

#register(opts, options) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/hiptest-publisher/options_parser.rb', line 76

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