Class: Xumlidot::Diagram::Dot

Inherits:
Object
  • Object
show all
Defined in:
lib/xumlidot/diagram/dot.rb,
lib/xumlidot/diagram/dot/klass.rb,
lib/xumlidot/diagram/dot/module.rb

Defined Under Namespace

Modules: Attribute, Klass, Method, Module

Instance Method Summary collapse

Constructor Details

#initialize(stack) ⇒ Dot

Returns a new instance of Dot.



9
10
11
12
# File 'lib/xumlidot/diagram/dot.rb', line 9

def initialize(stack)
  @stack = stack
  @output = []
end

Instance Method Details

#drawObject

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/xumlidot/diagram/dot.rb', line 16

def draw # rubocop:disable Metrics/AbcSize
  @output << header
  @stack.traverse do |klass|
    klass.extend(::Xumlidot::Diagram::Dot::Klass)
    @output << klass.draw
  end

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

    if ::Xumlidot::Options.inheritance
      output = klass.draw_inheritance
      @output << output unless output.nil?
    end

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

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