In Files

  • rdoc/ri/ri_options.rb

Files

Class/Module Index [+]

Quicksearch

RI::Options::OptionList

Constants

OPTION_LIST

Public Class Methods

error(msg) click to toggle source

Show an error and exit

 
               # File rdoc/ri/ri_options.rb, line 117
def OptionList.error(msg)
  $stderr.puts
  $stderr.puts msg
  name = File.basename $PROGRAM_NAME
  $stderr.puts "\nFor help on options, try '#{name} --help'\n\n"
  exit 1
end
            
options() click to toggle source
 
               # File rdoc/ri/ri_options.rb, line 95
def OptionList.options
  OPTION_LIST.map do |long, short, arg,|
    option = []
    option << long
    option << short unless short.nil?
    option << (arg ? GetoptLong::REQUIRED_ARGUMENT :
                     GetoptLong::NO_ARGUMENT)
    option
  end
end
            
strip_output(text) click to toggle source
 
               # File rdoc/ri/ri_options.rb, line 107
def OptionList.strip_output(text)
  text =~ /^\s+/
  leading_spaces = $&
  text.gsub!(/^#{leading_spaces}/, '')
  $stdout.puts text
end
            
usage(short_form=false) click to toggle source

Show usage and exit

 
               # File rdoc/ri/ri_options.rb, line 127
      def OptionList.usage(short_form=false)
        
        puts
        puts(RI::VERSION_STRING)
        puts
        
        name = File.basename($0)

        directories = [
          RI::Paths::SYSDIR,
          RI::Paths::SITEDIR,
          RI::Paths::HOMEDIR
        ]

        if RI::Paths::GEMDIRS then
          Gem.path.each do |dir|
            directories << "#{dir}/doc/*/ri"
          end
        end

        directories = directories.join("\n    ")

        OptionList.strip_output("          Usage:

            #{name} [options]  [names...]

          Display information on Ruby classes, modules, and methods.
          Give the names of classes or methods to see their documentation.
          Partial names may be given: if the names match more than
          one entity, a list will be shown, otherwise details on
          that entity will be displayed.

          Nested classes and modules can be specified using the normal
          Name::Name notation, and instance methods can be distinguished
          from class methods using "." (or "#") instead of "::".

          For example:

              #{name}  File
              #{name}  File.new
              #{name}  F.n
              #{name}  zip

          Note that shell quoting may be required for method names
          containing punctuation:

              #{name} 'Array.[]'
              #{name} compact\\!

          By default ri searches for documentation in the following
          directories:

              #{directories}

          Specifying the --system, --site, --home, --gems or --doc-dir
          options will limit ri to searching only the specified
          directories.

")

        if short_form
          puts "For help on options, type '#{name} -h'"
          puts "For a list of classes I know about, type '#{name} -c'"
        else
          puts "Options:\n\n"
          OPTION_LIST.each do|long, short, arg, desc|
            opt = ''
            opt << (short ? sprintf("%15s", "#{long}, #{short}") :
                            sprintf("%15s", long))
            if arg
              opt << " " << arg
            end
            print opt
            desc = desc.split("\n")
            if opt.size < 17
              print " "*(18-opt.size)
              puts desc.shift
            else
              puts
            end
            desc.each do |line|
              puts(" "*18 + line)
            end
            puts
          end
          puts "Options may also be passed in the 'RI' environment variable"
          exit 0
        end
      end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus