class Gem::OptionParser::Switch

def parse_arg(arg) # :nodoc:

:nodoc:

argument pattern. Yields when the pattern doesn't match substring.
Parses +arg+ and returns rest of +arg+ and matched portion to the
def parse_arg(arg) # :nodoc:
  pattern or return nil, [arg]
  unless m = pattern.match(arg)
    yield(InvalidArgument, arg)
    return arg, []
  end
  if String === m
    m = [s = m]
  else
    m = m.to_a
    s = m[0]
    return nil, m unless String === s
  end
  raise InvalidArgument, arg unless arg.rindex(s, 0)
  return nil, m if s.length == arg.length
  yield(InvalidArgument, arg) # didn't match whole arg
  return arg[s.length..-1], m
end