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



22
23
24
# File 'lib/xumlidot/diagram/dot/klass.rb', line 22

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

#draw_composition(composee) ⇒ Object



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

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

#draw_inheritenceObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xumlidot/diagram/dot/klass.rb', line 35

def draw_inheritence
  return nil if @definition.superklass.empty? && @definition.inherited_modules.empty?

  dot = ""
  if !@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.to_s}s\", arrowhead=\"empty\", arrowtail=\"onormal\"]\n"
  end

  dot
end

#draw_klassObject



26
27
28
29
# File 'lib/xumlidot/diagram/dot/klass.rb', line 26

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