Google

def add( child ) if child.kind_of? XMLDecl @children.unshift child elsif child.kind_of? DocType if @children[0].kind_of? XMLDecl @children[1,0] = child else @children.unshift child end else rv = super raise "attempted adding second root element to document" if @elements.size > 1 rv end end