Class: LilUtils::CLI::NumberedOption
- Defined in:
- lib/lilutils/cli/cli.rb
Overview
An Option with a name and a positive number used to identify its selection. This is useful when two Options start with the same character (e.g. “Chai” and “Coffee”)
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Attributes inherited from Option
Instance Method Summary collapse
-
#==(other) ⇒ Object
redefine.
-
#as_default ⇒ Object
redefine.
-
#as_non_default ⇒ Object
redefine.
-
#initialize(number, name) ⇒ NumberedOption
constructor
A new instance of NumberedOption.
- #to_s ⇒ Object
-
#valid_response(r) ⇒ Object
redefine.
Methods inherited from Option
Constructor Details
#initialize(number, name) ⇒ NumberedOption
Returns a new instance of NumberedOption.
84 85 86 87 |
# File 'lib/lilutils/cli/cli.rb', line 84 def initialize(number, name) super(name) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
82 83 84 |
# File 'lib/lilutils/cli/cli.rb', line 82 def number @number end |
Instance Method Details
#==(other) ⇒ Object
redefine
90 91 92 |
# File 'lib/lilutils/cli/cli.rb', line 90 def ==(other) @name == other.name && @number == other.number end |
#as_default ⇒ Object
redefine
100 101 102 |
# File 'lib/lilutils/cli/cli.rb', line 100 def as_default "*#{@name} (#{@number})*" end |
#as_non_default ⇒ Object
redefine
105 106 107 |
# File 'lib/lilutils/cli/cli.rb', line 105 def as_non_default "#{@name} (#{@number})" end |
#to_s ⇒ Object
109 110 111 |
# File 'lib/lilutils/cli/cli.rb', line 109 def to_s "#{@name}, #{number}" end |
#valid_response(r) ⇒ Object
redefine
95 96 97 |
# File 'lib/lilutils/cli/cli.rb', line 95 def valid_response(r) @number.to_s == r end |