Object
# File lib/eim_xml/formatter.rb, line 37 def indent(&proc) @indent_depth += 1 proc.call ensure @indent_depth -= 1 end
# File lib/eim_xml/formatter.rb, line 44 def preserve_space_element?(elm) @preservers && @preservers.any? do |e| case e when Symbol e==elm.name when Class e===elm end end end
# File lib/eim_xml/formatter.rb, line 22 def write(src) case src when ElementWrapper write_wrapper(src) when Comment write_comment(src) when Element write_element(src) when PCString write_pcstring(src) else write_string(src.to_s) end end
# File lib/eim_xml/formatter.rb, line 63 def write_comment(c) write_indent c.write_to(out) write_newline end
# File lib/eim_xml/formatter.rb, line 69 def write_contents_of(elm) flag = @preserve_space @preserve_space = true if preserve_space_element?(elm) write_newline indent do elm.contents.each do |c| write(c) end end write_indent ensure @preserve_space = flag end
# File lib/eim_xml/formatter.rb, line 83 def write_element(elm) write_indent out << "<" elm.name_and_attributes(out) case elm.contents.size when 0 out << " />" write_newline else out << ">" write_contents_of(elm) out << "</#{elm.name}>" write_newline end end
# File lib/eim_xml/formatter.rb, line 55 def write_indent out << @indent_string*@indent_depth unless @preserve_space end
# File lib/eim_xml/formatter.rb, line 59 def write_newline out << "\n" unless @preserve_space end
# File lib/eim_xml/formatter.rb, line 99 def write_pcstring(pcs) pcs.encoded_string.each_line do |l| write_indent out << l end write_newline end
Generated with the Darkfish Rdoc Generator 2.