Class RDoc::ClassModule

  1. lib/rdoc/code_objects.rb
Parent: RDoc::Context
ClassModule NormalModule AnonClass SingleClass NormalClass AnyMethod GhostMethod MetaMethod CodeObject Context Alias Attr Constant Require Include TopLevel RubyLex IRB RuntimeError Error Error Token TkUnknownChar TkVal TkNode TkOp TkId TkError TkOPASGN TkKW AttributeFormatter HtmlFormatter OverstrikeFormatter AnsiFormatter NamedThing AliasName IncludedModule Constant Attribute MethodSummary DefaultDisplay ClassEntry TopLevelEntry Formatter SimpleFormatter Description MethodDescription ModuleDescription ClassDescription HTML XML HTMLInOne CHM Method Context Class File Generator::MarkUp TEXINFO SimpleElement Port Element Node Subgraph Edge Digraph Stats Parser Options RDoc TemplatePage Markup Diagram NameDescriptor Cache Reader Writer Driver MethodEntry RI TexinfoTemplate AllReferences RubyToken Display Paths RI MarkUp Generator TokenStream DOT RDoc dot/f_5.png

ClassModule is the base class for objects representing either a class or a module.

Methods

public class

  1. new

public instance

  1. find_class_named
  2. full_name
  3. http_url
  4. module?
  5. superclass
  6. superclass=
  7. to_s

Attributes

diagram [RW]

Public class methods

new (name, superclass = nil)
[show source]
# File lib/rdoc/code_objects.rb, line 707
    def initialize(name, superclass = nil)
      @name       = name
      @diagram    = nil
      @superclass = superclass
      @comment    = ""
      super()
    end

Public instance methods

find_class_named (name)
[show source]
# File lib/rdoc/code_objects.rb, line 715
    def find_class_named(name)
      return self if full_name == name
      @classes.each_value {|c| return c if c.find_class_named(name) }
      nil
    end
full_name ()

Return the fully qualified name of this class or module

[show source]
# File lib/rdoc/code_objects.rb, line 724
    def full_name
      if @parent && @parent.full_name
        @parent.full_name + "::" + @name
      else
        @name
      end
    end
http_url (prefix)
[show source]
# File lib/rdoc/code_objects.rb, line 732
    def http_url(prefix)
      path = full_name.split("::")
      File.join(prefix, *path) + ".html"
    end
module? ()

Does this object represent a module?

[show source]
# File lib/rdoc/code_objects.rb, line 740
    def module?
      false
    end
superclass ()

Get the superclass of this class. Attempts to retrieve the superclass’ real name by following module nesting.

[show source]
# File lib/rdoc/code_objects.rb, line 748
    def superclass
      raise NoMethodError, "#{full_name} is a module" if module?

      scope = self

      begin
        superclass = scope.classes.find { |c| c.name == @superclass }

        return superclass.full_name if superclass
        scope = scope.parent
      end until scope.nil? or TopLevel === scope

      @superclass
    end
superclass= (superclass)

Set the superclass of this class

[show source]
# File lib/rdoc/code_objects.rb, line 766
    def superclass=(superclass)
      raise NoMethodError, "#{full_name} is a module" if module?

      if @superclass.nil? or @superclass == 'Object' then
        @superclass = superclass 
      end
    end
to_s ()
[show source]
# File lib/rdoc/code_objects.rb, line 774
    def to_s
      "#{self.class}: #{@name} #{@comment} #{super}"
    end