Class: ArgParser::Option
Instance Attribute Summary collapse
-
#param ⇒ Object
(also: #argument)
readonly
These attrs are from the manifest that is applied through constructor.
Attributes inherited from Argument
#count, #default, #help, #multiple, #required, #validate, #value
Instance Method Summary collapse
-
#name ⇒ Object
Returns first name as a ‘default’ one when several names given.
-
#names ⇒ Object
Names of an option (short, long, etc.).
- #synopsis ⇒ Object
Methods inherited from Argument
#add_value, #initialize, #printed_help, #reset, #set_default, #to_s, #valid?, #value?
Methods included from Tools
Constructor Details
This class inherits a constructor from ArgParser::Argument
Instance Attribute Details
#param ⇒ Object (readonly) Also known as: argument
These attrs are from the manifest that is applied through constructor
6 7 8 |
# File 'lib/argparser/option.rb', line 6 def param @param end |
Instance Method Details
#name ⇒ Object
Returns first name as a ‘default’ one when several names given
8 9 10 |
# File 'lib/argparser/option.rb', line 8 def name @name ||= names.first end |
#names ⇒ Object
Names of an option (short, long, etc.)
15 16 17 |
# File 'lib/argparser/option.rb', line 15 def names @names ||= [@name] end |
#synopsis ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/argparser/option.rb', line 19 def synopsis s = names.map{|n| n.size == 1 ? "-#{n}" : "--#{n}"}.join(', ') s << " #{param}" if param s = "[#{s}]" if !required s << '...' if multiple s end |