Class: OptParseValidator::OptCredentials
- Defined in:
- lib/opt_parse_validator/opts/credentials.rb
Overview
Implementation of the Credentials Option
Instance Attribute Summary
Attributes inherited from OptBase
Instance Method Summary collapse
-
#validate(value) ⇒ Hash
A hash containing the :username and :password.
Methods inherited from OptBase
#advanced?, #alias?, #append_help_messages, #choices, #default, #help_message_for_default, #help_messages, #initialize, #normalize, #required?, #required_unless, #to_long, #to_s, #to_sym, #value_if_empty
Constructor Details
This class inherits a constructor from OptParseValidator::OptBase
Instance Method Details
#validate(value) ⇒ Hash
Returns A hash containing the :username and :password.
7 8 9 10 11 12 13 |
# File 'lib/opt_parse_validator/opts/credentials.rb', line 7 def validate(value) raise Error, 'Incorrect credentials format, username:password expected' unless value.index(':') creds = value.split(':', 2) { username: creds[0], password: creds[1] } end |