In Files

Parent

Files

IHelp::IHelpDriver

Version of RiDriver that takes its options as parameter to initialize.

Attributes

display[RW]
ri_reader[RW]

Public Class Methods

new(args = (ENV["RI"] || "").split) click to toggle source

Create new IHelpDriver, with the given args passed to @options, which is a RI::Options.instance

# File lib/ihelp.rb, line 499
def initialize(args = (ENV["RI"] || "").split)
  @options = RI::Options.instance
  @options.parse(args)

  paths =  (if RUBY_VERSION > "1.8.4"
              @options.doc_dir
            else
              @options.paths
            end) || RI::Paths::PATH
  if paths.empty?
    report_missing_documentation(paths)
  end
  @ri_reader = RI::RiReader.new(RI::RiCache.new(paths))
  @display   = @options.displayer
end

Public Instance Methods

display_info(info) click to toggle source

Display the info based on if it's for a class or a method. Using ri's pager.

# File lib/ihelp.rb, line 538
def display_info(info)
  case [info.class] # only info.class doesn't work
  when [RI::ClassDescription]
    @display.display_class_info(info, @ri_reader)
  when [RI::MethodDescription]
    @display.display_method_info(info)
  end
end
get_class_info_str(namespaces, klass_name) click to toggle source

Get info for the class in the given namespaces.

# File lib/ihelp.rb, line 549
def get_class_info_str(namespaces, klass_name)
  return nil if namespaces.empty?
  klass_name_last = klass_name.split("::").last
  klass = nil
  namespaces.find{|ns|
    begin
      ns.name == klass_name_last and
      klass = @ri_reader.get_class(ns)
    rescue TypeError
      nil
    end
  }
  klass
end
get_info_str(klass_name, method_name = nil, instance = false) click to toggle source

Get info string from ri database for klass_name [method_name]

# File lib/ihelp.rb, line 517
def get_info_str(klass_name, method_name = nil, instance = false)
  is_class_method = (not instance)
  top_level_namespace = @ri_reader.top_level_namespace
  namespaces = klass_name.split(/::/).inject(top_level_namespace){
    |ns, current_name|
    @ri_reader.lookup_namespace_in(current_name, ns)
  }
  return nil if namespaces.empty?
  if method_name.nil?
    get_class_info_str(namespaces, klass_name)
  else
    methods = @ri_reader.find_methods(
                method_name, is_class_method, namespaces)
    return nil if methods.empty?
    get_method_info_str(method_name, methods)
  end
end
get_method_info_str(requested_method_name, methods) click to toggle source

Get info for the method in the given methods.

# File lib/ihelp.rb, line 566
def get_method_info_str(requested_method_name, methods)
  entries = methods.find_all {|m| m.name == requested_method_name}
  return nil if entries.empty?
  method = nil
  entries.find{|entry| method = @ri_reader.get_method(entry)}
  method
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.