Module: TTY::Option::Parser::ParamTypes
- Included in:
- Arguments, Environments, Keywords, Options
- Defined in:
- lib/tty/option/parser/param_types.rb
Constant Summary collapse
- ARGUMENT_PARAMETER =
Positional argument pattern
/^[^-][^=]*\z/.freeze
- ENV_VAR_PARAMETER =
Environment variable pattern
/^[\p{Lu}_\-\d]+=/.freeze
- KEYWORD_PARAMETER =
Keyword pattern
/^([^-=][\p{Ll}_\-\d]*)=([^=]+)/.freeze
- OPTION_PARAMETER =
Option and flag pattern
/^-./.freeze
Instance Method Summary collapse
-
#argument?(value) ⇒ Boolean
Check if value looks like an argument.
-
#env_var?(value) ⇒ Boolean
Check if value is an environment variable.
-
#keyword?(value) ⇒ Boolean
Check to see if value is a keyword.
-
#option?(value) ⇒ Boolean
Check if value looks like an option.
Instance Method Details
#argument?(value) ⇒ Boolean
Check if value looks like an argument
26 27 28 |
# File 'lib/tty/option/parser/param_types.rb', line 26 def argument?(value) !value.match(ARGUMENT_PARAMETER).nil? end |
#env_var?(value) ⇒ Boolean
Check if value is an environment variable
37 38 39 |
# File 'lib/tty/option/parser/param_types.rb', line 37 def env_var?(value) !value.match(ENV_VAR_PARAMETER).nil? end |
#keyword?(value) ⇒ Boolean
Check to see if value is a keyword
46 47 48 |
# File 'lib/tty/option/parser/param_types.rb', line 46 def keyword?(value) !value.to_s.match(KEYWORD_PARAMETER).nil? end |
#option?(value) ⇒ Boolean
Check if value looks like an option
57 58 59 |
# File 'lib/tty/option/parser/param_types.rb', line 57 def option?(value) !value.match(OPTION_PARAMETER).nil? end |