123456789_123456789_123456789_123456789_123456789_

Class: Gem::OptionParser::AC

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

Constant Summary

::Gem::OptionParser - Inherited

ArgumentStyle, COMPSYS_HEADER, DecimalInteger, DecimalNumeric, DefaultList, NoArgument, OctalInteger, Officious, OptionalArgument, RequiredArgument, SPLAT_PROC, Version

Class Method Summary

::Gem::OptionParser - Inherited

.accept

See #accept.

.each_const,
.getopts
.inc

Returns an incremented value of default according to arg.

.new

Initializes the instance and yields itself if called with a block.

.reject

See #reject.

.search_const, .show_version, .terminate, .top,
.with

Initializes a new instance and evaluates the optional block in context of the instance.

Instance Attribute Summary

::Gem::OptionParser - Inherited

#banner

Heading banner preceding summary.

#banner=

Heading banner preceding summary.

#default_argv

Strings to be parsed in default.

#program_name

Program name to be emitted in error message and default banner, defaults to $0.

#program_name=

Program name to be emitted in error message and default banner, defaults to $0.

#raise_unknown

Whether to raise at unknown option.

#release

Release code.

#release=

Release code.

#require_exact

Whether to require that options match exactly (disallows providing abbreviated long option as short option).

#summary_indent

Indentation for summary.

#summary_width

Width for option list portion of summary.

#version
#version=

Instance Method Summary

::Gem::OptionParser - Inherited

#abort,
#accept

Directs to accept specified class t.

#additional_message

Returns additional info.

#base

Subject of #on_tail.

#candidate,
#def_head_option

Alias for #define_head.

#def_option

Alias for #define.

#def_tail_option

Alias for #define_tail.

#define
#define_by_keywords
#define_head
#define_tail
#environment

Parses environment variable env or its uppercase with splitting like a shell.

#getopts

Wrapper method for getopts.rb.

#help

Returns option summary string.

#inc,
#load

Loads options from file names as filename.

#make_switch
#new

Pushes a new List.

#on
#on_head
#on_tail
#order

Parses command line arguments argv in order.

#order!

Same as #order, but removes switches destructively.

#parse

Parses command line arguments argv in order when environment variable POSIXLY_CORRECT is set, and in permutation mode otherwise.

#parse!

Same as #parse, but removes switches destructively.

#permute

Parses command line arguments argv in permutation mode and returns list of non-option arguments.

#permute!

Same as #permute, but removes switches destructively.

#reject

Directs to reject specified class argument.

#remove

Removes the last List.

#separator

Add separator in summary.

#summarize

Puts option summary into to and returns to.

#terminate

Terminates option parsing.

#to_a

Returns option summary list.

#to_s

Alias for #help.

#top

Subject of #on / #on_head, #accept / #reject

#ver

Returns version string from program_name, version and release.

#warn, #add_officious, #compsys, #inspect, #pretty_print,
#complete

Completes shortened long style option switch and returns pair of canonical switch and switch descriptor Switch.

#notwice

Checks if an argument is given twice, in which case an ArgumentError is raised.

#parse_in_order,
#search

Searches key in @stack for id hash and returns or yields the result.

#visit

Traverses @stack, sending each element method id with args and block.

Constructor Details

This class inherits a constructor from Gem::OptionParser

Instance Method Details

#_ac_arg_enable(prefix, name, help_string, block) (private)

[ GitHub ]

  
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 18

def _ac_arg_enable(prefix, name, help_string, block)
  _check_ac_args(name, block)

  sdesc = []
  ldesc = ["--#{prefix}-#{name}"]
  desc = [help_string]
  q = name.downcase
  ac_block = proc {|val| block.call(ARG_CONV.call(val))}
  enable = Switch::PlacedArgument.new(nil, ARG_CONV, sdesc, ldesc, nil, desc, ac_block)
  disable = Switch::NoArgument.new(nil, proc {false}, sdesc, ldesc, nil, desc, ac_block)
  top.append(enable, [], ["enable-" + q], disable, ['disable-' + q])
  enable
end

#_check_ac_args(name, block) (private)

[ GitHub ]

  
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 7

def _check_ac_args(name, block)
  unless /\A\w[-\w]*\z/ =~ name
    raise ArgumentError, name
  end
  unless block
    raise ArgumentError, "no block given", ParseError.filter_backtrace(caller)
  end
end

#ac_arg_disable(name, help_string, &block)

[ GitHub ]

  
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 38

def ac_arg_disable(name, help_string, &block)
  _ac_arg_enable("disable", name, help_string, block)
end

#ac_arg_enable(name, help_string, &block)

[ GitHub ]

  
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 34

def ac_arg_enable(name, help_string, &block)
  _ac_arg_enable("enable", name, help_string, block)
end

#ac_arg_with(name, help_string, &block)

[ GitHub ]

  
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 42

def ac_arg_with(name, help_string, &block)
  _check_ac_args(name, block)

  sdesc = []
  ldesc = ["--with-#{name}"]
  desc = [help_string]
  q = name.downcase
  with = Switch::PlacedArgument.new(*search(:atype, String), sdesc, ldesc, nil, desc, block)
  without = Switch::NoArgument.new(nil, proc {}, sdesc, ldesc, nil, desc, block)
  top.append(with, [], ["with-" + q], without, ['without-' + q])
  with
end