Class: CLIArgValidator
- Inherits:
-
Object
- Object
- CLIArgValidator
- Defined in:
- lib/pry-globs/cli_arg_validator.rb
Constant Summary collapse
- CONSTANT_TOKENS =
('A'..'Z').to_a << '_'
- ERROR_MESSAGES =
{ 'invalid_options' => 'Only one option is supported: \'-e (explanation)\'.', 'invalid_identifier_count' => "Globs accepts only one argument: e.g. '$!'.", 'invalid_identifier_token' => 'Invalid Ruby identifier. It has to be valid global variable ("$0") or a valid constant token. ("RUBY_VERSION")', 'invalid_argument_presence' => 'You have to pass at least one argument and it has to be an identifier.' }.freeze
Instance Attribute Summary collapse
-
#cli_args ⇒ Object
readonly
Returns the value of attribute cli_args.
Instance Method Summary collapse
- #args_invalid? ⇒ Boolean
- #args_invalid_msg ⇒ Object
-
#initialize(cli_args) ⇒ CLIArgValidator
constructor
A new instance of CLIArgValidator.
Constructor Details
#initialize(cli_args) ⇒ CLIArgValidator
Returns a new instance of CLIArgValidator.
13 14 15 |
# File 'lib/pry-globs/cli_arg_validator.rb', line 13 def initialize(cli_args) @cli_args = cli_args end |
Instance Attribute Details
#cli_args ⇒ Object (readonly)
Returns the value of attribute cli_args.
11 12 13 |
# File 'lib/pry-globs/cli_arg_validator.rb', line 11 def cli_args @cli_args end |
Instance Method Details
#args_invalid? ⇒ Boolean
17 18 19 |
# File 'lib/pry-globs/cli_arg_validator.rb', line 17 def args_invalid? invalid_argument_presence? || || identifiers_invalid? end |
#args_invalid_msg ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/pry-globs/cli_arg_validator.rb', line 21 def args_invalid_msg method_names = %w(options identifier_count identifier_token argument_presence) method_names.each_with_object([]) do |method, memo| method = "invalid_#{method}" memo << ERROR_MESSAGES[method] if send("#{method}?") end.join("\n\n") end |