In Files

  • rdoc/ri/ri_cache.rb

Files

Class/Module Index [+]

Quicksearch

RI::ClassEntry

Attributes

name[R]
path_names[R]

Public Class Methods

new(path_name, name, in_class) click to toggle source
 
               # File rdoc/ri/ri_cache.rb, line 8
def initialize(path_name, name, in_class)
  @path_names = [ path_name ]
  @name = name
  @in_class = in_class
  @class_methods    = []
  @instance_methods = []
  @inferior_classes = []
end
            

Public Instance Methods

add_path(path) click to toggle source

We found this class in more tha one place, so add in the name from there.

 
               # File rdoc/ri/ri_cache.rb, line 19
def add_path(path)
  @path_names << path
end
            
all_method_names() click to toggle source

Return a list of all out method names

 
               # File rdoc/ri/ri_cache.rb, line 102
def all_method_names
  res = @class_methods.map {|m| m.full_name }
  @instance_methods.each {|m| res << m.full_name}
  res
end
            
classes_and_modules() click to toggle source
 
               # File rdoc/ri/ri_cache.rb, line 67
def classes_and_modules
  @inferior_classes
end
            
contained_class_named(name) click to toggle source

Return an exact match to a particular name

 
               # File rdoc/ri/ri_cache.rb, line 72
def contained_class_named(name)
  @inferior_classes.find {|c| c.name == name}
end
            
contained_modules_matching(name) click to toggle source

Return a list of any classes or modules that we contain that match a given string

 
               # File rdoc/ri/ri_cache.rb, line 63
def contained_modules_matching(name)
  @inferior_classes.find_all {|c| c.name[name]}
end
            
full_name() click to toggle source

Return our full name

 
               # File rdoc/ri/ri_cache.rb, line 95
def full_name
  res = @in_class.full_name
  res << "::" unless res.empty?
  res << @name
end
            
load_from(dir) click to toggle source

read in our methods and any classes and modules in our namespace. Methods are stored in files called name-c|i.yaml, where the 'name' portion is the external form of the method name and the c|i is a class|instance flag

 
               # File rdoc/ri/ri_cache.rb, line 30
def load_from(dir)
  Dir.foreach(dir) do |name|
    next if name =~ /^\./

    # convert from external to internal form, and
    # extract the instance/class flag

    if name =~ /^(.*?)-(c|i).yaml$/
      external_name = $1
      is_class_method = $2 == "c"
      internal_name = RiWriter.external_to_internal(external_name)
      list = is_class_method ? @class_methods : @instance_methods
      path = File.join(dir, name)
      list << MethodEntry.new(path, internal_name, is_class_method, self)
    else
      full_name = File.join(dir, name)
      if File.directory?(full_name)
        inf_class = @inferior_classes.find {|c| c.name == name }
        if inf_class
          inf_class.add_path(full_name)
        else
          inf_class = ClassEntry.new(full_name, name, self)
          @inferior_classes << inf_class
        end
        inf_class.load_from(full_name)
      end
    end
  end
end
            
methods_matching(name, is_class_method) click to toggle source

return the list of local methods matching name We're split into two because we need distinct behavior when called from the toplevel

 
               # File rdoc/ri/ri_cache.rb, line 79
def methods_matching(name, is_class_method)
  local_methods_matching(name, is_class_method)
end
            
recursively_find_methods_matching(name, is_class_method) click to toggle source

Find methods matching 'name' in ourselves and in any classes we contain

 
               # File rdoc/ri/ri_cache.rb, line 85
def recursively_find_methods_matching(name, is_class_method)
  res = local_methods_matching(name, is_class_method)
  @inferior_classes.each do |c|
    res.concat(c.recursively_find_methods_matching(name, is_class_method))
  end
  res
end