3 def initialize(source
= nil)
5 read(source
) unless source
.nil?
10 doc
= Document
.new(source
)
11 raise InvalidErdFile
unless doc
.elements
.to_a
.length
== 1 and doc
.elements
[1].name
.downcase
== 'drawing'
12 self.mark
= doc
.elements
['Drawing'].attributes
["mark"].to_f
13 self.name
= Label
.new doc
.elements
['Drawing'].attributes
["name"]
14 doc
.elements
.each('Drawing/box') do |box_element
|
15 self << Box
.new(box_element
)
17 doc
.elements
.each('Drawing/link') do |link_element
|
18 self << Link
.new(link_element
, self.vertices
)
20 doc
.elements
.each('Drawing/selfLink') do |link_element
|
21 self << Link
.new(link_element
, self.vertices
)
26 # The minimal meaningful units of an ERD are:
27 # Each box in isolation
28 # Each link, with the associated boxes at its ends
31 self.vertices
.each
do |b
|
36 self.edges
.each
do |l
|
38 l
.vertices
.each
do |b
|