Class: FastRI::RiIndex::ClassEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/fastri/ri_index.rb

Direct Known Subclasses

TopLevelEntry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ri_index, fullname, index, source_index) ⇒ ClassEntry

Returns a new instance of ClassEntry.



125
126
127
128
129
130
131
# File 'lib/fastri/ri_index.rb', line 125

def initialize(ri_index, fullname, index, source_index)
  @ri_index = ri_index
  @full_name = fullname
  @name = fullname.split(/::/).last
  @index = index
  @source_index = source_index
end

Instance Attribute Details

#full_nameObject (readonly)

Returns the value of attribute full_name.



123
124
125
# File 'lib/fastri/ri_index.rb', line 123

def full_name
  @full_name
end

#indexObject (readonly)

Returns the value of attribute index.



123
124
125
# File 'lib/fastri/ri_index.rb', line 123

def index
  @index
end

#nameObject (readonly)

Returns the value of attribute name.



123
124
125
# File 'lib/fastri/ri_index.rb', line 123

def name
  @name
end

#source_indexObject (readonly)

Returns the value of attribute source_index.



123
124
125
# File 'lib/fastri/ri_index.rb', line 123

def source_index
  @source_index
end

Instance Method Details

#all_method_namesObject

Returns all methods, both instance and singleton (non-recursive).



179
180
181
# File 'lib/fastri/ri_index.rb', line 179

def all_method_names
  @ri_index.methods_under(self, false, @source_index).map{|meth| meth.full_name}
end

#classes_and_modulesObject

Returns all nested classes and modules (non-recursive).



153
154
155
# File 'lib/fastri/ri_index.rb', line 153

def classes_and_modules
  @ri_index.namespaces_under(self, false, @source_index)
end

#contained_class_named(name) ⇒ Object

Returns nested class or module named exactly name (non-recursive).



158
159
160
# File 'lib/fastri/ri_index.rb', line 158

def contained_class_named(name)
  contained_modules_matching(name).find{|x| x.name == name}
end

#contained_modules_matching(name) ⇒ Object

Returns nested classes and modules matching name (non-recursive).



146
147
148
149
150
# File 'lib/fastri/ri_index.rb', line 146

def contained_modules_matching(name)
  @ri_index.namespaces_under(self, false, @source_index).select do |x|
    x.name[name]
  end
end

#methods_matching(name, is_class_method) ⇒ Object

Returns instance or singleton methods matching name (non-recursive).



163
164
165
166
167
168
# File 'lib/fastri/ri_index.rb', line 163

def methods_matching(name, is_class_method)
  @ri_index.methods_under(self, false, @source_index).select do |meth|
    meth.name[name] &&
      (is_class_method ? meth.singleton_method? : meth.instance_method?)
  end
end

#path_namesObject

Returns an array of directory names holding the cdesc-Classname.yaml files.



135
136
137
138
139
140
141
142
143
# File 'lib/fastri/ri_index.rb', line 135

def path_names
  prefix = @full_name.split(/::/)
  case @source_index
  when nil
    @ri_index.source_paths_for(self).map{|path| File.join(path, *prefix) }
  else
    [File.join(@ri_index.paths[@source_index], *prefix)]
  end
end

#recursively_find_methods_matching(name, is_class_method) ⇒ Object

Returns instance or singleton methods matching name (recursive).



171
172
173
174
175
176
# File 'lib/fastri/ri_index.rb', line 171

def recursively_find_methods_matching(name, is_class_method)
  @ri_index.methods_under(self, true, @source_index).select do |meth|
    meth.name[name] && 
      (is_class_method ? meth.singleton_method? : meth.instance_method?)
  end
end

#typeObject

Returns the type of this entry (:namespace).



184
185
186
# File 'lib/fastri/ri_index.rb', line 184

def type
  :namespace
end