Class: RI::ClassEntry

Class | RI::ClassEntry
In: | rdoc/ri/ri_cache.rb
Parent: | Object

### Methods

add_path all_method_names classes_and_modules contained_class_named contained_modules_matching full_name load_from methods_matching new recursively_find_methods_matching

### Attributes

name | [R] |
path_names | [R] |

### Public Class methods

new(path_name, name, in_class)

[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)

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

[Source]

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

all_method_names()

Return a list of all out method names

[Source]

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

[Source]

    # File rdoc/ri/ri_cache.rb, line 67
        def classes_and_modules
          @inferior_classes
        end

contained_class_named(name)

Return an exact match to a particular name

[Source]

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

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

[Source]

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

full_name()

Return our full name

[Source]

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

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

[Source]

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

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

[Source]

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

Find methods matching ‘name’ in ourselves and in any classes we contain

[Source]

    # 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

[Validate]