diff options
Diffstat (limited to 'lib/rexml/node.rb')
-rw-r--r-- | lib/rexml/node.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb index 7226e5be6c..9780376829 100644 --- a/lib/rexml/node.rb +++ b/lib/rexml/node.rb @@ -1,4 +1,6 @@ require "rexml/parseexception" +require "rexml/formatters/pretty" +require "rexml/formatters/default" module REXML # Represents a node in the tree. Nodes are never encountered except as @@ -18,10 +20,19 @@ module REXML @parent[ ind - 1 ] end - def to_s indent=-1 - rv = "" - write rv,indent - rv + # indent:: + # *DEPRECATED* This parameter is now ignored. See the formatters in the + # REXML::Formatters package for changing the output style. + def to_s indent=nil + unless indent.nil? + Kernel.warn( "#{self.class.name}.to_s(indent) parameter is deprecated" ) + f = REXML::Formatters::Pretty.new( indent ) + f.write( self, rv, indent ) + else + f = REXML::Formatters::Default.new + f.write( self, rv = "" ) + end + return rv end def indent to, ind |