class Xumlidot::Diagram::Dot

Public Class Methods

new(stack, options = nil) click to toggle source
# File lib/xumlidot/diagram/dot.rb, line 8
def initialize(stack, options = nil)
  @stack = stack
  @options = options
  @output = []
end

Public Instance Methods

draw() click to toggle source

We have to draw any connecting labels AFTER we have drawn the klasses in order to have something to connect.

# File lib/xumlidot/diagram/dot.rb, line 16
def draw
  @output << header
  @stack.traverse do |klass|
    klass.extend(::Xumlidot::Diagram::Dot::Klass)
    @output << klass.draw
  end

  @stack.traverse do |klass|
    # Check - i shouldnt need to extend twice
    klass.extend(::Xumlidot::Diagram::Dot::Klass)

    if @options.inheritance
      output = klass.draw_inheritence
      @output << output unless output.nil?
    end

    if @options.composition
      klass.constants.each do |k|
        @output << klass.draw_composition(k)
      end
    end
  end
  @output << footer

  @output.uniq.each { |l| puts l }
end

Private Instance Methods

header() click to toggle source
# File lib/xumlidot/diagram/dot.rb, line 45
def header
  %(digraph graph_title {
      graph[overlap=false, splines=true, bgcolor="white"])
end