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

Methods

Attributes

name  [R] 
path_names  [R] 

Public Class methods

[Source]

    # File ri/ri_cache.rb, line 8
 8:     def initialize(path_name, name, in_class)
 9:       @path_names = [ path_name ]
10:       @name = name
11:       @in_class = in_class
12:       @class_methods    = []
13:       @instance_methods = []
14:       @inferior_classes = []
15:     end

Public Instance methods

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

[Source]

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

Return a list of all out method names

[Source]

     # File ri/ri_cache.rb, line 102
102:     def all_method_names
103:       res = @class_methods.map {|m| m.full_name }
104:       @instance_methods.each {|m| res << m.full_name}
105:       res
106:     end

[Source]

    # File ri/ri_cache.rb, line 67
67:     def classes_and_modules
68:       @inferior_classes
69:     end

Return an exact match to a particular name

[Source]

    # File ri/ri_cache.rb, line 72
72:     def contained_class_named(name)
73:       @inferior_classes.find {|c| c.name == name}
74:     end

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

[Source]

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

Return our full name

[Source]

    # File ri/ri_cache.rb, line 95
95:     def full_name
96:       res = @in_class.full_name
97:       res << "::" unless res.empty?
98:       res << @name
99:     end

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 ri/ri_cache.rb, line 30
30:     def load_from(dir)
31:       Dir.foreach(dir) do |name|
32:         next if name =~ /^\./
33: 
34:         # convert from external to internal form, and
35:         # extract the instance/class flag
36: 
37:         if name =~ /^(.*?)-(c|i).yaml$/
38:           external_name = $1
39:           is_class_method = $2 == "c"
40:           internal_name = RiWriter.external_to_internal(external_name)
41:           list = is_class_method ? @class_methods : @instance_methods
42:           path = File.join(dir, name)
43:           list << MethodEntry.new(path, internal_name, is_class_method, self)
44:         else
45:           full_name = File.join(dir, name)
46:           if File.directory?(full_name)
47:             inf_class = @inferior_classes.find {|c| c.name == name }
48:             if inf_class
49:               inf_class.add_path(full_name)
50:             else
51:               inf_class = ClassEntry.new(full_name, name, self)
52:               @inferior_classes << inf_class
53:             end
54:             inf_class.load_from(full_name)
55:           end
56:         end
57:       end
58:     end

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 ri/ri_cache.rb, line 79
79:     def methods_matching(name, is_class_method)
80:       local_methods_matching(name, is_class_method)
81:     end

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

[Source]

    # File ri/ri_cache.rb, line 85
85:     def recursively_find_methods_matching(name, is_class_method)
86:       res = local_methods_matching(name, is_class_method)
87:       @inferior_classes.each do |c|
88:         res.concat(c.recursively_find_methods_matching(name, is_class_method))
89:       end
90:       res
91:     end

[Validate]