123456789_123456789_123456789_123456789_123456789_

Class: OptionParser::Switch::PlacedArgument

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: OptionParser::Switch
Defined in: lib/optparse.rb

Overview

::OptionParser::Switch that takes an argument, which does not begin with '-'.

Class Method Summary

::OptionParser::Switch - Inherited

.guess

Guesses argument style from #arg.

.incompatible_argument_styles, .new, .pattern

Instance Attribute Summary

Instance Method Summary

::OptionParser::Switch - Inherited

#summarize

Produces the summary text.

#switch_name

Main name of the switch.

#conv_arg

Parses argument, converts and returns #arg, #block and result of conversion.

#parse_arg

Parses #arg and returns rest of #arg and matched portion to the argument pattern.

#add_banner, #compsys, #match_nonswitch?

Constructor Details

This class inherits a constructor from OptionParser::Switch

Instance Method Details

#parse(arg, argv, &error)

Returns nil if argument is not present or begins with '-'.

[ GitHub ]

  
# File 'lib/optparse.rb', line 705

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