class Gem::OptionParser::List


matching pattern and converter pair. Also provides summary feature.
string to Gem::OptionParser::Switch and mapping from acceptable argument to
Simple option list providing mapping from short and/or long option

def accept(t, pat = /.*/m, &block)


See Gem::OptionParser.accept.
def accept(t, pat = /.*/m, &block)
  if pat
    pat.respond_to?(:match) or
      raise TypeError, "has no 'match'", ParseError.filter_backtrace(caller(2))
  else
    pat = t if t.respond_to?(:match)
  end
  unless block
    block = pat.method(:convert).to_proc if pat.respond_to?(:convert)
  end
  @atype[t] = [pat, block]
end

def add_banner(to) # :nodoc:

:nodoc:
def add_banner(to)  # :nodoc:
  list.each do |opt|
    if opt.respond_to?(:add_banner)
      opt.add_banner(to)
    end
  end
  to
end

def append(*args)


append(switch, short_opts, long_opts, nolong_opts)

+nolong_opts+:: List of long style options with "no-" prefix.
+long_opts+:: List of long style options.
+short_opts+:: List of short style options.
+switch+:: Gem::OptionParser::Switch instance to be inserted.

and negated long options. Arguments are:
Appends +switch+ at the tail of the list, and associates short, long
def append(*args)
  update(*args)
  @list.push(args[0])
end

def complete(id, opt, icase = false, *pat, &block)


returned.
is returned or yielded if a block is given. If it isn't found, nil is
+pat+. If +icase+ is true, the search is case insensitive. The result
Searches list +id+ for +opt+ and the optional patterns for completion
def complete(id, opt, icase = false, *pat, &block)
  __send__(id).complete(opt, icase, *pat, &block)
end

def compsys(*args, &block) # :nodoc:

:nodoc:
def compsys(*args, &block)  # :nodoc:
  list.each do |opt|
    if opt.respond_to?(:compsys)
      opt.compsys(*args, &block)
    end
  end
end

def each_option(&block)


Iterates over each option, passing the option to the +block+.
def each_option(&block)
  list.each(&block)
end

def get_candidates(id)

def get_candidates(id)
  yield __send__(id).keys
end

def initialize


Just initializes all instance variables.
def initialize
  @atype = {}
  @short = OptionMap.new
  @long = OptionMap.new
  @list = []
end

def prepend(*args)


prepend(switch, short_opts, long_opts, nolong_opts)

+nolong_opts+:: List of long style options with "no-" prefix.
+long_opts+:: List of long style options.
+short_opts+:: List of short style options.
+switch+:: Gem::OptionParser::Switch instance to be inserted.

and negated long options. Arguments are:
Inserts +switch+ at the head of the list, and associates short, long
def prepend(*args)
  update(*args)
  @list.unshift(args[0])
end

def pretty_print(q) # :nodoc:

:nodoc:
def pretty_print(q)         # :nodoc:
  q.group(1, "(", ")") do
    @list.each do |sw|
      next unless Switch === sw
      q.group(1, "(" + sw.pretty_head, ")") do
        sw.pretty_print_contents(q)
      end
    end
  end
end

def reject(t)


See Gem::OptionParser.reject.
def reject(t)
  @atype.delete(t)
end

def search(id, key)


block is given. If it isn't found, nil is returned.
Searches +key+ in +id+ list. The result is returned or yielded if a
def search(id, key)
  if list = __send__(id)
    val = list.fetch(key) {return nil}
    block_given? ? yield(val) : val
  end
end

def summarize(*args, &block)


method which is called on every option.
newline). The arguments +args+ are passed along to the summarize
Creates the summary table, passing each line to the +block+ (without
def summarize(*args, &block)
  sum = []
  list.reverse_each do |opt|
    if opt.respond_to?(:summarize) # perhaps Gem::OptionParser::Switch
      s = []
      opt.summarize(*args) {|l| s << l}
      sum.concat(s.reverse)
    elsif !opt or opt.empty?
      sum << ""
    elsif opt.respond_to?(:each_line)
      sum.concat([*opt.each_line].reverse)
    else
      sum.concat([*opt.each].reverse)
    end
  end
  sum.reverse_each(&block)
end

def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:

:nodoc:

+nlopts+:: Negated long style options list.
+lopts+:: Long style option list.
+sopts+:: Short style option list.
+sw+:: Gem::OptionParser::Switch instance to be added.

Adds +sw+ according to +sopts+, +lopts+ and +nlopts+.
def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
  sopts.each {|o| @short[o] = sw} if sopts
  lopts.each {|o| @long[o] = sw} if lopts
  nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
  used = @short.invert.update(@long.invert)
  @list.delete_if {|o| Switch === o and !used[o]}
end