ClassModule is the base class for objects representing either a class or a module.
Creates a new ClassModule with name with optional superclass
# File lib/rdoc/class_module.rb, line 16
16: def initialize(name, superclass = 'Object')
17: @diagram = nil
18: @full_name = nil
19: @name = name
20: @superclass = superclass
21: super()
22: end
Ancestors list for this ClassModule (abstract)
# File lib/rdoc/class_module.rb, line 27
27: def ancestors
28: raise NotImplementedError
29: end
Finds a class or module with name in this namespace or its descendents
# File lib/rdoc/class_module.rb, line 47
47: def find_class_named(name)
48: return self if full_name == name
49: return self if @name == name
50:
51: @classes.values.find do |klass|
52: next if klass == self
53: klass.find_class_named name
54: end
55: end
Return the fully qualified name of this class or module
# File lib/rdoc/class_module.rb, line 60
60: def full_name
61: @full_name ||= if RDoc::ClassModule === @parent then
62: "#{@parent.full_name}::#{@name}"
63: else
64: @name
65: end
66: end
Merges class_module into this ClassModule
# File lib/rdoc/class_module.rb, line 147
147: def merge class_module
148: comment = class_module.comment
149:
150: if comment then
151: document = parse @comment
152:
153: comment.parts.concat document.parts
154:
155: @comment = comment
156: end
157:
158: class_module.each_attribute do |attr|
159: if match = attributes.find { |a| a.name == attr.name } then
160: match.rw = [match.rw, attr.rw].compact.join
161: else
162: add_attribute attr
163: end
164: end
165:
166: class_module.each_constant do |const|
167: add_constant const
168: end
169:
170: class_module.each_include do |incl|
171: add_include incl
172: end
173:
174: class_module.each_method do |meth|
175: add_method meth
176: end
177: end
Does this object represent a module?
# File lib/rdoc/class_module.rb, line 182
182: def module?
183: false
184: end
Path to this class or module
# File lib/rdoc/class_module.rb, line 189
189: def path
190: http_url RDoc::RDoc.current.generator.class_dir
191: end
Get the superclass of this class. Attempts to retrieve the superclass object, returns the name if it is not known.
# File lib/rdoc/class_module.rb, line 197
197: def superclass
198: RDoc::TopLevel.find_class_named_from(@superclass, parent) || @superclass
199: end
Set the superclass of this class to superclass
# File lib/rdoc/class_module.rb, line 204
204: def superclass=(superclass)
205: raise NoMethodError, "#{full_name} is a module" if module?
206:
207: @superclass = superclass if @superclass.nil? or @superclass == 'Object'
208: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.
Appends comment to the current comment, but separated by a rule. Works more like +=.
# File lib/rdoc/class_module.rb, line 35 35: def comment=(comment) 36: return if comment.empty? 37: 38: comment = "#{@comment}\n---\n#{normalize_comment comment}" unless 39: @comment.empty? 40: 41: super 42: end