Module: Xumlidot::Diagram::Dot::Klass

Includes:
Shared::Naming
Included in:
Module
Defined in:
lib/xumlidot/diagram/dot/klass.rb

Instance Method Summary collapse

Methods included from Shared::Naming

#draw_ancestor, #draw_identifier, #draw_name

Instance Method Details

#drawObject



30
31
32
# File 'lib/xumlidot/diagram/dot/klass.rb', line 30

def draw
  [draw_klass].compact.join('\r\n')
end

#draw_composition(composee) ⇒ Object



39
40
41
42
43
# File 'lib/xumlidot/diagram/dot/klass.rb', line 39

def draw_composition(composee)
  "\"#{draw_identifier(composee.definition)}\"" \
    " -> \"#{draw_identifier(@definition)}\"" \
    ' [label="", arrowhead="diamond", arrowtail="diamond"]'
end

#draw_inheritanceObject

rubocop:disable Metrics/AbcSize



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/xumlidot/diagram/dot/klass.rb', line 45

def draw_inheritance # rubocop:disable Metrics/AbcSize
  return nil if @definition.superklass.empty? && @definition.inherited_modules.empty?

  dot = ''
  unless @definition.superklass.empty?
    dot += "\"#{draw_identifier(@definition)}\"" \
           " -> \"#{draw_ancestor(@definition.superklass)}\"" \
           " [label=\"\", arrowhead=\"empty\", arrowtail=\"onormal\"]\n"
  end

  return dot if @definition.inherited_modules.empty?

  @definition.inherited_modules.each do |m|
    next if m.empty?

    dot += "\"#{draw_identifier(@definition)}\"" \
           " -> \"#{draw_ancestor(m)}\"" \
           " [label=\"#{m.type}s\", arrowhead=\"empty\", arrowtail=\"onormal\"]\n"
  end

  dot
end

#draw_klassObject



34
35
36
37
# File 'lib/xumlidot/diagram/dot/klass.rb', line 34

def draw_klass
  label = draw_identifier(@definition)
  "\"#{draw_identifier(@definition)}\" [shape=Mrecord, label=\"{#{label}|#{draw_methods}}\"]"
end