PageRenderTime 29ms CodeModel.GetById 24ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/Ruby/lib/ruby/1.8/rexml/cdata.rb

http://github.com/agross/netopenspace
Ruby | 67 lines | 27 code | 6 blank | 34 comment | 0 complexity | f8a8d577ba28b9ed094ae7f9265a031c MD5 | raw file
 1require "rexml/text"
 2
 3module REXML
 4	class CData < Text
 5		START = '<![CDATA['
 6		STOP = ']]>'
 7		ILLEGAL = /(\]\]>)/
 8
 9		#	Constructor.  CData is data between <![CDATA[ ... ]]>
10		#
11		# _Examples_
12		#  CData.new( source )
13		#  CData.new( "Here is some CDATA" )
14		#  CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
15		def initialize( first, whitespace=true, parent=nil )
16			super( first, whitespace, parent, true, true, ILLEGAL )
17		end
18
19		# Make a copy of this object
20		# 
21		# _Examples_
22		#  c = CData.new( "Some text" )
23		#  d = c.clone
24		#  d.to_s        # -> "Some text"
25		def clone
26			CData.new self
27		end
28
29		# Returns the content of this CData object
30		#
31		# _Examples_
32		#  c = CData.new( "Some text" )
33		#  c.to_s        # -> "Some text"
34		def to_s
35			@string
36		end
37
38    def value
39      @string
40    end
41
42    # == DEPRECATED
43    # See the rexml/formatters package
44    #
45		# Generates XML output of this object
46		#
47		# output::
48		#   Where to write the string.  Defaults to $stdout
49		# indent::
50    #   The amount to indent this node by
51		# transitive::
52    #   Ignored
53		# ie_hack::
54    #   Ignored
55		#
56		# _Examples_
57		#  c = CData.new( " Some text " )
58		#  c.write( $stdout )     #->  <![CDATA[ Some text ]]>
59		def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
60      Kernel.warn( "#{self.class.name}.write is deprecated" )
61			indent( output, indent )
62			output << START
63			output << @string
64			output << STOP
65		end
66	end
67end