Methods
A
P
R
Class Public methods
all_classes()

Returns an array of all classes recorded thus far.

# File lib/erbook/rdoc.rb, line 16
    def self.all_classes
      @all_classes.values
    end
all_methods()

Returns an array of RDoc::AnyMethod objects representing all methods recorded thus far.

# File lib/erbook/rdoc.rb, line 31
    def self.all_methods
      all_classes_and_modules.map {|c| c.method_list }.flatten
    end
all_modules()

Returns an array of all modules recorded thus far.

# File lib/erbook/rdoc.rb, line 23
    def self.all_modules
      @all_modules.values
    end
parse(code_string, file_name = __FILE__)

Returns a RDoc::TopLevel object containing information parsed from the given code string. This information is also added to the global TopLevel class state, so you can access it via the class methods of the TopLevel class.

If the file name (which signifies the origin of the given code) is given, it MUST have a “.c” or “.rb” file extension. Otherwise, RDoc will ignore the given code string! :-(

# File lib/erbook/rdoc.rb, line 65
    def self.parse code_string, file_name = __FILE__
      tl = TopLevel.new(file_name)
      op = DummyOptions.new
      st = Stats.new(0)

      result = Parser.for(tl, file_name, code_string, op, st).scan

      refresh_all_classes_and_modules

      result
    end
parse_file(file_name)

Returns a RDoc::TopLevel object containing information parsed from the code in the given file. This information is also added to the global TopLevel class state, so you can access it via the class methods of the TopLevel class.

The given file name MUST have a “.c” or “.rb” file extension. Otherwise, RDoc will ignore the file! :-(

# File lib/erbook/rdoc.rb, line 86
    def self.parse_file file_name
      parse File.read(file_name), file_name
    end
refresh_all_classes_and_modules()

Update the return value of the all_classes_and_modules() method to really include every class and every module seen thus far.

# File lib/erbook/rdoc.rb, line 39
    def self.refresh_all_classes_and_modules
      visit = lambda do |node|
        if node.is_a? NormalClass or node.is_a? SingleClass
          @all_classes[node.full_name] = node

        elsif node.is_a? NormalModule
          @all_modules[node.full_name] = node
        end

        (node.classes + node.modules).each {|n| visit[n] }
      end

      all_classes_and_modules.each {|n| visit[n] }
    end