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 )


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

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"


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

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"


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

def to_s
  @string
end

#valueObject



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

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 ]]>


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

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