# OptionParser::Switch::List (Class)

In: | optparse.rb
Parent: | Object

## Methods

accept append complete new prepend reject search summarize

## Attributes

atype | [R] |
list | [R] |
long | [R] |
short | [R] |

## Public Class methods

new()

[Source]

    # File optparse.rb, line 507
        def initialize
          @atype = {}
          @short = OptionMap.new
          @long = OptionCaseMap.new
          @list = []
        end

## Public Instance methods

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

[Source]

    # File optparse.rb, line 535
        def accept(t, pat = /.*/, &block)
          if pat
            pat.respond_to?(:match) or raise TypeError, "has no `match'"
          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

reject(t)

[Source]

    # File optparse.rb, line 547
        def reject(t)
          @atype.delete(t)
        end

prepend(*args)

[Source]

    # File optparse.rb, line 592
        def prepend(*args)
          update(*args)
          @list.unshift(args[0])
        end

append(*args)

[Source]

    # File optparse.rb, line 597
        def append(*args)
          update(*args)
          @list.push(args[0])
        end

search(id, key) {|val| ...}

[Source]

    # File optparse.rb, line 613
        def search(id, key)
          if list = __send__(id)
            val = list.fetch(key) {return nil}
            return val unless block_given?
            yield(val)
          end
        end

complete(id, opt, *pat, &block)

[Source]

    # File optparse.rb, line 634
        def complete(id, opt, *pat, &block)
          __send__(id).complete(opt, *pat, &block)
        end

summarize(*args, &block) {|""| ...}

[Source]

    # File optparse.rb, line 648
        def summarize(*args, &block)
          list.each do |opt|
            if opt.respond_to?(:summarize) # perhaps OptionParser::Switch

              opt.summarize(*args, &block)
            elsif opt.empty?
              yield("")
            else
              opt.each(&block)
            end
          end
        end

[Validate]