X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=lib%2Ferd_handler%2Fbox.rb;h=75543eb22674b1dcc92f5734dcc6ea6366a929e3;hb=042a27abb3ac3bf9faf36406204fe1d1901123d3;hp=7389955d4b58d2927efc70703e9b3e966f799ded;hpb=5cb26987412346fc34cb344d7b169c0784f1da77;p=erd-marker.git diff --git a/lib/erd_handler/box.rb b/lib/erd_handler/box.rb index 7389955..75543eb 100644 --- a/lib/erd_handler/box.rb +++ b/lib/erd_handler/box.rb @@ -8,7 +8,7 @@ module ErdHandler def read(box_element) self.id = box_element.attributes["id"].to_i - self.name = box_element.attributes["name"] + self.name = Label.new box_element.attributes["name"] self.mark = box_element.attributes["mark"].to_f self.x = box_element.elements["location"].attributes["x"].to_f @@ -19,5 +19,14 @@ module ErdHandler self end + def contains?(other) + self.x < other.x and self.x + self.width > other.x + other.width and + self.y < other.y and self.y + self.height > other.y + other.height + end + + def within?(other) + other.contains?(self) + end + end end