Class: Gem::OptionParser::AC
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Gem::OptionParser
|
|
Instance Chain:
self,
::Gem::OptionParser
|
|
Inherits: |
Gem::OptionParser
|
Defined in: | lib/rubygems/optparse/lib/optparse/ac.rb |
Constant Summary
-
ARG_CONV =
# File 'lib/rubygems/optparse/lib/optparse/ac.rb', line 16proc {|val| val.nil? ? true : val}
::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 | See #getopts. |
.inc | Returns an incremented value of |
.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
- #ac_arg_disable(name, help_string, &block)
- #ac_arg_enable(name, help_string, &block)
- #ac_arg_with(name, help_string, &block)
- #_ac_arg_enable(prefix, name, help_string, block) private
- #_check_ac_args(name, block) private
::Gem::OptionParser
- Inherited
#abort, | |
#accept | Directs to accept specified class |
#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 |
#getopts | Wrapper method for getopts.rb. |
#help | Returns option summary string. |
#inc, | |
#load | Loads options from file names as |
#make_switch | |
#new | Pushes a new |
#on | |
#on_head | |
#on_tail | |
#order | Parses command line arguments |
#order! | Same as #order, but removes switches destructively. |
#parse | Parses command line arguments |
#parse! | Same as #parse, but removes switches destructively. |
#permute | Parses command line arguments |
#permute! | Same as #permute, but removes switches destructively. |
#reject | Directs to reject specified class argument. |
#remove | Removes the last |
#separator | Add separator in summary. |
#summarize | Puts option summary into |
#terminate | Terminates option parsing. |
#to_a | Returns option summary list. |
#to_s | Alias for #help. |
#top | |
#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 |
#notwice | Checks if an argument is given twice, in which case an ArgumentError is raised. |
#parse_in_order, | |
#search | Searches |
#visit | Traverses @stack, sending each element method |
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/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/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/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/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/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