All pastes #822676 Raw Edit

partitialxmlgen

public ruby v1 · immutable
·published 2007-12-18 21:46 UTC
rendered paste body
class Xlement    #Store the tag and initialize the array of children    def initialize(tag)        @tag = tag        @sharp_objects = Array.new        @attributes = Hash.new #USEME    end        #Add an element inside this element    def swallow(sharp_object)        @sharp_objects << sharp_object    end        #Squeeze it put    def heimlich()        print '<', @tag, '>'        @sharp_objects.each do |sharp_object|            if sharp_object.respond_to? :heimlich                sharp_object.heimlich            else                print sharp_object if sharp_object.respond_to? :to_s            end        end        print '</', @tag, '>'    endend