Class: REXML::CData

Inherits:
Text show all
Defined in:
lib/rexml/cdata.rb

Constant Summary collapse

START =
'<![CDATA['
STOP =
']]>'
ILLEGAL =
/(\]\]>)/

Constants inherited from Text

Text::NEEDS_A_SECOND_CHECK, Text::NUMERICENTITY, Text::REFERENCE, Text::SETUTITSBUS, Text::SLAICEPS, Text::SPECIALS, Text::SUBSTITUTES, Text::VALID_CHAR, Text::VALID_XML_CHARS

Instance Attribute Summary

Attributes inherited from Text

#raw

Attributes inherited from Child

#parent

Instance Method Summary collapse

Methods inherited from Text

#<<, #<=>, check, #doctype, #empty?, #indent_text, #inspect, #node_type, #parent=, #value=, #wrap, #write_with_substitution, #xpath

Methods inherited from Child

#bytes, #document, #next_sibling=, #previous_sibling=, #remove, #replace_with

Methods included from Node

#each_recursive, #find_first_recursive, #indent, #index_in_parent, #next_sibling_node, #parent?, #previous_sibling_node

Constructor Details

#initialize(first, whitespace = true, parent = nil) ⇒ CData

Constructor. CData is data between <![CDATA[ … ]]>

Examples

CData.new( source )
CData.new( "Here is some CDATA" )
CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )


15
16
17
# File 'lib/rexml/cdata.rb', line 15

def initialize( first, whitespace=true, parent=nil )
  super( first, whitespace, parent, false, true, ILLEGAL )
end

Instance Method Details

#cloneObject

Make a copy of this object

Examples

c = CData.new( "Some text" )
d = c.clone
d.to_s        # -> "Some text"


25
26
27
# File 'lib/rexml/cdata.rb', line 25

def clone
  CData.new self
end

#to_sObject

Returns the content of this CData object

Examples

c = CData.new( "Some text" )
c.to_s        # -> "Some text"


34
35
36
# File 'lib/rexml/cdata.rb', line 34

def to_s
  @string
end

#valueObject



38
39
40
# File 'lib/rexml/cdata.rb', line 38

def value
  @string
end

#write(output = $stdout, indent = -1,, transitive = false, ie_hack = false) ⇒ Object

DEPRECATED

See the rexml/formatters package

Generates XML output of this object

output

Where to write the string. Defaults to $stdout

indent

The amount to indent this node by

transitive

Ignored

ie_hack

Ignored

Examples

c = CData.new( " Some text " )
c.write( $stdout )     #->  <![CDATA[ Some text ]]>


59
60
61
62
63
64
65
# File 'lib/rexml/cdata.rb', line 59

def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
  Kernel.warn( "#{self.class.name}.write is deprecated" )
  indent( output, indent )
  output << START
  output << @string
  output << STOP
end