Method: UCD::Formatter::Graphviz#format_class

Defined in:
lib/ucd/formatter/graphviz.rb

#format_class(node) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/ucd/formatter/graphviz.rb', line 116

def format_class(node)
  name = "<B>#{node.name}</B>"
  name = "«abstract»<BR/><I>#{name}</I>" if node.modifier == "abstract"
  name = "«interface»<BR/>#{name}" if node.modifier == "interface"

  unless node.fields.empty?
    field_rows  = node.fields.map { |field| %Q{<TR><TD ALIGN="LEFT">#{format_field(field)}</TD></TR>}}
    field_table = "\n  <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n\#{field_rows.map { |row| \" \" * 10 + row }.join(\"\\n\")}\n  </TABLE>\n".chomp
    field_table << "\n" << " " * 6
  end

  unless node.methods.empty?
    method_rows  = node.methods.map { |method| %Q{<TR><TD ALIGN="LEFT">#{format_method(method)}</TD></TR>}}
    method_table = "\n  <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n\#{method_rows.map { |row| \" \" * 10 + row }.join(\"\\n\")}\n  </TABLE>\n".chomp
    method_table << "\n" << " " * 6
  end

  "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n    <TR>\n<TD>\#{name}</TD>\n    </TR>\n    <TR>\n<TD>\#{field_table}</TD>\n    </TR>\n    <TR>\n<TD>\#{method_table}</TD>\n    </TR>\n  </TABLE>\n".chomp
end