Flowdock
method

add_classes

Importance_0
add_classes(container, graph, file = nil ) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rdoc/diagram.rb, line 168
    def add_classes(container, graph, file = nil )

      use_fileboxes = @options.fileboxes

      files = {}

      # create dummy node (needed if empty and for module includes)
      if container.full_name
        graph << DOT::Node.new('name'     => "#{container.full_name.gsub( /:/,'_' )}",
                               'label'    => "",
                               'width'  => (container.classes.empty? and
                                            container.modules.empty?) ?
                               '0.75' : '0.01',
                               'height' => '0.01',
                               'shape' => 'plaintext')
      end

      container.classes.each_with_index do |cl, cl_index|
        last_file = cl.in_files[-1].file_relative_name

        if use_fileboxes && !files.include?(last_file)
          @counter += 1
          files[last_file] =
            DOT::Subgraph.new('name'     => "cluster_#{@counter}",
                                 'label'    => "#{last_file}",
                                 'fontname' => FONT,
                                 'color'=>
                                 last_file == file ? 'red' : 'black')
        end

        next if cl.name == 'Object' || cl.name[0,2] == "<<"

        url = cl.http_url("classes")

        label = cl.name.dup
        if use_fileboxes && cl.in_files.length > 1
          label <<  '\n[' +
                        cl.in_files.collect {|i|
                             i.file_relative_name
                        }.sort.join( '\n' ) +
                    ']'
        end

        attrs = {
          'name' => "#{cl.full_name.gsub( /:/, '_' )}",
          'fontcolor' => 'black',
          'style'=>'filled',
          'color'=>'palegoldenrod',
          'label' => label,
          'shape' => 'ellipse',
          'URL'   => %{"#{url}"}
        }

        c = DOT::Node.new(attrs)

        if use_fileboxes
          files[last_file].push c
        else
          graph << c
        end
      end

      if use_fileboxes
        files.each_value do |val|
          graph << val
        end
      end

      unless container.classes.empty?
        container.classes.each_with_index do |cl, cl_index|
          cl.includes.each do |m|
            m_full_name = find_full_name(m.name, cl)
            if @local_names.include?(m_full_name)
              @global_graph << DOT::Edge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
                                             'to' => "#{cl.full_name.gsub( /:/,'_' )}",
                                             'ltail' => "cluster_#{m_full_name.gsub( /:/,'_' )}")
            else
              unless @global_names.include?(m_full_name)
                path = m_full_name.split("::")
                url = File.join('classes', *path) + ".html"
                @global_graph << DOT::Node.new('name' => "#{m_full_name.gsub( /:/,'_' )}",
                                               'shape' => 'box',
                                               'label' => "#{m_full_name}",
                                               'URL'   => %{"#{url}"})
                @global_names << m_full_name
              end
              @global_graph << DOT::Edge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
                                             'to' => "#{cl.full_name.gsub( /:/, '_')}")
            end
          end

          sclass = cl.superclass
          next if sclass.nil? || sclass == 'Object'
          sclass_full_name = find_full_name(sclass,cl)
          unless @local_names.include?(sclass_full_name) or @global_names.include?(sclass_full_name)
            path = sclass_full_name.split("::")
            url = File.join('classes', *path) + ".html"
            @global_graph << DOT::Node.new('name' => "#{sclass_full_name.gsub( /:/, '_' )}",
                                           'label' => sclass_full_name,
                                           'URL'   => %{"#{url}"})
            @global_names << sclass_full_name
          end
          @global_graph << DOT::Edge.new('from' => "#{sclass_full_name.gsub( /:/,'_' )}",
                                         'to' => "#{cl.full_name.gsub( /:/, '_')}")
        end
      end

      container.modules.each do |submod|
        draw_module(submod, graph)
      end

    end
Register or log in to add new notes.