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

In Files

  • rdoc/ri/ri_display.rb

Files

Class/Module Index [+]

Quicksearch

DefaultDisplay

A paging display module. Uses the ri_formatter class to do the actual presentation

Public Class Methods

new(options) click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 41
def initialize(options)
  @options = options
  @formatter = @options.formatter.new(@options, "     ")
end
            

Public Instance Methods

display_class_info(klass, ri_reader) click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 76
def display_class_info(klass, ri_reader)
  page do 
    superclass = klass.superclass_string
    
    if superclass
      superclass = " < " + superclass
    else
      superclass = ""
    end
    
    @formatter.draw_line(klass.display_name + ": " +
                         klass.full_name + superclass)
    
    display_flow(klass.comment)
    @formatter.draw_line 
  
    unless klass.includes.empty?
      @formatter.blankline
      @formatter.display_heading("Includes:", 2, "")
      incs = []
      klass.includes.each do |inc|
        inc_desc = ri_reader.find_class_by_name(inc.name)
        if inc_desc
          str = inc.name + "("
          str << inc_desc.instance_methods.map{|m| m.name}.join(", ")
          str << ")"
          incs << str
        else
          incs << inc.name
        end
    end
      @formatter.wrap(incs.sort.join(', '))
    end
    
    unless klass.constants.empty?
      @formatter.blankline
      @formatter.display_heading("Constants:", 2, "")
      len = 0
      klass.constants.each { |c| len = c.name.length if c.name.length > len }
      len += 2
      klass.constants.each do |c|
        @formatter.wrap(c.value, 
                        @formatter.indent+((c.name+":").ljust(len)))
      end 
    end
    
    unless klass.class_methods.empty?
      @formatter.blankline
      @formatter.display_heading("Class methods:", 2, "")
      @formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', '))
    end
    
    unless klass.instance_methods.empty?
      @formatter.blankline
      @formatter.display_heading("Instance methods:", 2, "")
      @formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', '))
    end
    
    unless klass.attributes.empty?
      @formatter.blankline
      @formatter.wrap("Attributes:", "")
      @formatter.wrap(klass.attributes.map{|a| a.name}.sort.join(', '))
    end
  end
end
            
display_class_list(namespaces) click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 156
def display_class_list(namespaces)
  page do
    puts "More than one class or module matched your request. You can refine"
    puts "your search by asking for information on one of:\n\n"
    @formatter.wrap(namespaces.map {|m| m.full_name}.join(", "))
  end
end
            
display_method_info(method) click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 58
def display_method_info(method)
  page do
    @formatter.draw_line(method.full_name)
    display_params(method)
    @formatter.draw_line
    display_flow(method.comment)
    if method.aliases && !method.aliases.empty?
      @formatter.blankline
      aka = "(also known as "
      aka << method.aliases.map {|a| a.name }.join(", ") 
      aka << ")"
      @formatter.wrap(aka)
    end
  end
end
            
display_method_list(methods) click to toggle source

Display a list of method names

 
               # File rdoc/ri/ri_display.rb, line 146
def display_method_list(methods)
  page do
    puts "More than one method matched your request. You can refine"
    puts "your search by asking for information on one of:\n\n"
    @formatter.wrap(methods.map {|m| m.full_name} .join(", "))
  end
end
            
display_usage() click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 49
def display_usage
  page do
    RI::Options::OptionList.usage(short_form=true)
  end
end
            
list_known_classes(classes) click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 166
def list_known_classes(classes)
  if classes.empty?
    warn_no_database
  else
    page do 
      @formatter.draw_line("Known classes and modules")
      @formatter.blankline
      @formatter.wrap(classes.sort.join(", "))
    end
  end
end
            
list_known_names(names) click to toggle source
 
               # File rdoc/ri/ri_display.rb, line 180
def list_known_names(names)
  if names.empty?
    warn_no_database
  else
    page do 
      names.each {|n| @formatter.raw_print_line(n)}
    end
  end
end