DocumentStructure defines and restricts structure of document tree. it consists of ElementRelationship
# File lib/rd/document-struct.rb, line 6 def initialize @relationships = [] end
# File lib/rd/document-struct.rb, line 10 def add_relationships(*relations) @relationships += relations end
# File lib/rd/document-struct.rb, line 14 def define_relationship(parent, child) add_relationships(ElementRelationship.new(parent, child)) end
# File lib/rd/document-struct.rb, line 18 def each_relationship @relationships.each do |i| yield(i) end end
# File lib/rd/document-struct.rb, line 24 def is_valid?(parent, child) each_relationship do |i| return true if i.match?(parent, child) end false end