Class: OptParseValidator::OptArray
- Defined in:
- lib/opt_parse_validator/opts/array.rb
Overview
Implementation of the Array Option
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from OptBase
Instance Method Summary collapse
- #append_help_messages ⇒ Void
-
#normalize(values) ⇒ Object
See OptBase#normalize.
-
#separator ⇒ String
The separator used to split the string into an array.
- #validate(value) ⇒ Array
Methods inherited from OptBase
#advanced?, #alias?, #choices, #default, #help_message_for_default, #help_messages, #initialize, #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
#append_help_messages ⇒ Void
7 8 9 10 11 |
# File 'lib/opt_parse_validator/opts/array.rb', line 7 def option << "Separator to use between the values: '#{separator}'" super end |
#normalize(values) ⇒ Object
See OptBase#normalize
27 28 29 30 31 32 |
# File 'lib/opt_parse_validator/opts/array.rb', line 27 def normalize(values) values.each_with_index do |value, index| values[index] = super(value) end values end |
#separator ⇒ String
Returns The separator used to split the string into an array.
21 22 23 |
# File 'lib/opt_parse_validator/opts/array.rb', line 21 def separator attrs[:separator] || ',' end |
#validate(value) ⇒ Array
16 17 18 |
# File 'lib/opt_parse_validator/opts/array.rb', line 16 def validate(value) super(value).split(separator) end |