Class: RI::Options

Class | RI::Options
In: | rdoc/ri/ri_options.rb
Parent: | Object

### Methods

displayer new parse paths show_version

### Included Modules

Singleton

### Classes and Modules

Module RI::Options::OptionList

### 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()

[Source]

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

### Public Instance methods

displayer()

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)

[Source]

    # File rdoc/ri/ri_options.rb, line 250
        def displayer
          ::RiDisplay.new(self)
        end

parse(args)

Parse command line options.

[Source]

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

          old_argv = ARGV.dup
    #      if ENV["RI"]
    #        ARGV.replace(ENV["RI"].split.concat(ARGV))
    #      end

         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 "--doc-dir"
                if File.directory?(arg)
                  @doc_dir = 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

paths()

Return the doc_dir as an array, or nil if no overriding doc dir was given

[Source]

    # File rdoc/ri/ri_options.rb, line 242
        def paths
          defined?(@doc_dir) ? [ @doc_dir ] : nil
        end

show_version()

Show the version and exit

[Source]

    # File rdoc/ri/ri_options.rb, line 172
        def show_version
          puts VERSION_STRING
          exit(0)
        end

[Validate]