Extended maintenance of Ruby versions 1.8.7 and 1.9.2 will end on July 31, 2014. Read more

In Files

  • rdoc/ri/ri_options.rb

Parent

Namespace

Included Modules

Files

Class/Module Index [+]

Quicksearch

RI::Options

Attributes

doc_dir[R]

the directory we search for original documentation

formatter[R]

the formatting we apply to the output

list_classes[R]

should we just display a class list and exit

list_names[R]

should we display a list of all names

use_stdout[RW]

No not use a pager. Writable, because ri sets it if it can’t find a pager

width[R]

The width of the output line

Public Class Methods

new() click to toggle source
 
               # File rdoc/ri/ri_options.rb, line 225
def initialize
  @use_stdout   = !STDOUT.tty?
  @width        = 72
  @formatter    = RI::TextFormatter.for("plain") 
  @list_classes = false
  @list_names   = false

  # By default all paths are used.  If any of these are true, only those
  # directories are used.
  @use_system = false
  @use_site = false
  @use_home = false
  @use_gems = false
  @doc_dirs = []
end
            

Public Instance Methods

displayer() click to toggle source

Return an instance of the displayer (the thing that actually writes the information). This allows us to load in new displayer classes at runtime (for example to help with IDE integration)

 
               # File rdoc/ri/ri_options.rb, line 313
def displayer
  ::RiDisplay.new(self)
end
            
parse(args) click to toggle source

Parse command line options.

 
               # File rdoc/ri/ri_options.rb, line 243
def parse(args)

  old_argv = ARGV.dup

  ARGV.replace(args)

  begin

    go = GetoptLong.new(*OptionList.options)
    go.quiet = true

    go.each do |opt, arg|
      case opt
      when "--help"       then OptionList.usage
      when "--version"    then show_version
      when "--list-names" then @list_names = true
      when "--no-pager"   then @use_stdout = true
      when "--classes"    then @list_classes = true

      when "--system"     then @use_system = true
      when "--site"       then @use_site = true
      when "--home"       then @use_home = true
      when "--gems"       then @use_gems = true

      when "--doc-dir"
        if File.directory?(arg)
          @doc_dirs << arg
        else
          $stderr.puts "Invalid directory: #{arg}"
          exit 1
        end

      when "--format"
        @formatter = RI::TextFormatter.for(arg)
        unless @formatter
          $stderr.print "Invalid formatter (should be one of "
          $stderr.puts RI::TextFormatter.list + ")"
          exit 1
        end
      when "--width"
        begin
          @width = Integer(arg)
        rescue 
          $stderr.puts "Invalid width: '#{arg}'"
          exit 1
        end
      end
    end

  rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
    OptionList.error(error.message)

  end
end
            
path() click to toggle source

Return the selected documentation directories.

 
               # File rdoc/ri/ri_options.rb, line 300
def path
  RI::Paths.path(@use_system, @use_site, @use_home, @use_gems, *@doc_dirs)
end
            
raw_path() click to toggle source
 
               # File rdoc/ri/ri_options.rb, line 304
def raw_path
  RI::Paths.raw_path(@use_system, @use_site, @use_home, @use_gems,
                     *@doc_dirs)
end
            
show_version() click to toggle source

Show the version and exit

 
               # File rdoc/ri/ri_options.rb, line 220
def show_version
  puts VERSION_STRING
  exit(0)
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