Class: ArgParser::ValueArgument Abstract
- Defined in:
- lib/arg-parser/argument.rb
Overview
Abstract base class of arguments that take a value (i.e. positional and keyword arguments).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#sensitive ⇒ Boolean
(also: #sensitive?)
Flag indicating that the value for this argument is a sensitive value (e.g. a password) that should not be displayed.
-
#usage_value ⇒ String
A label that will be used in the usage string printed for this ValueArgument.
-
#validation ⇒ Array, ...
An optional validation that will be applied to the argument value for this argument, to determine if it is valid.
Attributes inherited from Argument
#default, #description, #key, #on_parse, #required, #short_key, #usage_break
Method Summary
Methods inherited from Argument
Instance Attribute Details
#sensitive ⇒ Boolean Also known as: sensitive?
Returns Flag indicating that the value for this argument is a sensitive value (e.g. a password) that should not be displayed.
147 148 149 |
# File 'lib/arg-parser/argument.rb', line 147 def sensitive @sensitive end |
#usage_value ⇒ String
Returns A label that will be used in the usage string printed for this ValueArgument. If not specified, defaults to the upper-case value of the argument key. For example, if the argument key is :foo_bar, the default usage value for this argument would be FOO-BAR, as in:
Usage:
my-prog.rb FOO-BAR.
168 169 170 |
# File 'lib/arg-parser/argument.rb', line 168 def usage_value @usage_value end |
#validation ⇒ Array, ...
Returns An optional validation that will be applied to the argument value for this argument, to determine if it is valid. The validation can take the following forms:
@param [Array] If an Array is specified, the supplied value will be
checked to verify it is one of the allowed values specified in the
Array.
@param [Regexp] If a Regexp object is supplied, the argument value
will be tested against the Regexp to verify it is valid.
@param [Proc] The most flexible option; the supplied value, this
ValueArgument sub-class object, and the parse results (thus far)
will be passed to the Proc for validation. The Proc must return a
non-falsey value for the argument to be accepted.
161 162 163 |
# File 'lib/arg-parser/argument.rb', line 161 def validation @validation end |