class OptParseValidator::OptSmartList

Implementation of the SmartList Option Such option allow users to supply a list like

Public Instance Methods

append_help_messages() click to toggle source

@return [ Void ]

# File lib/opt_parse_validator/opts/smart_list.rb, line 11
def append_help_messages
  super
  # removes the help message from OptArray about the separator as useless here
  # can't use option as it's an attr_reader only
  @option -= ["Separator to use between the values: '#{separator}'"]

  option << "Examples: 'a1', '#{%w[a1 a2 a3].join(separator)}', '/tmp/a.txt'"
end
validate(value) click to toggle source

@param [ String ] value

@return [ Array<String> ]

Calls superclass method OptParseValidator::OptArray#validate
# File lib/opt_parse_validator/opts/smart_list.rb, line 23
def validate(value)
  # Might be a better way to do this especially with a big file
  File.open(value).map(&:chomp)
rescue Errno::ENOENT
  super(value)
end