Method: OptionParser::Switch::PlacedArgument#parse

Defined in:
lib/optparse.rb

#parse(arg, argv, &error) ⇒ Object

Returns nil if argument is not present or begins with ‘-’ and is not ‘-’.



790
791
792
793
794
795
796
797
798
799
800
801
802
803
# File 'lib/optparse.rb', line 790

def parse(arg, argv, &error)
  if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
    return nil, block
  end
  opt = (val = parse_arg(val, &error))[1]
  val = conv_arg(*val)
  if opt and !arg
    argv.shift
  else
    omitted_argument val
    val[0] = nil
  end
  val
end