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
#choices, #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
5 6 7 |
# File 'lib/opt_parse_validator/opts/array.rb', line 5 def option << "Separator to use between the values: '#{separator}'" end |
#normalize(values) ⇒ Object
See OptBase#normalize
23 24 25 26 27 28 |
# File 'lib/opt_parse_validator/opts/array.rb', line 23 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.
17 18 19 |
# File 'lib/opt_parse_validator/opts/array.rb', line 17 def separator attrs[:separator] || ',' end |
#validate(value) ⇒ Array
12 13 14 |
# File 'lib/opt_parse_validator/opts/array.rb', line 12 def validate(value) super(value).split(separator) end |