123456789_123456789_123456789_123456789_123456789_

Class: REXML::CData

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Text, Child
Instance Chain:
self, Text, Comparable, Child, Node
Inherits: REXML::Text
Defined in: lib/rexml/cdata.rb

Constant Summary

Text - Inherited

EREFERENCE, NEEDS_A_SECOND_CHECK, NUMERICENTITY, REFERENCE, SETUTITSBUS, SLAICEPS, SPECIALS, SUBSTITUTES, VALID_CHAR, VALID_XML_CHARS

Class Method Summary

Text - Inherited

.check

check for illegal characters.

.new

Constructor arg if a String, the content is set to the String.

.expand,
.normalize

Escapes all possible entities.

.read_with_substitution

Reads text, substituting entities.

.unnormalize

Unescapes all possible entities.

Child - Inherited

.new

Constructor.

Instance Attribute Summary

Text - Inherited

#raw

If raw is true, then ::REXML leaves the value alone.

#value

Returns the string value of this text.

#value=

Sets the contents of this text node.

#empty?, #parent=

Child - Inherited

#next_sibling
#next_sibling=

Sets the next sibling of this child.

#parent

The Parent of this object.

#parent=

Sets the parent of this child to the supplied argument.

#previous_sibling
#previous_sibling=

Sets the previous sibling of this child.

Node - Included

Instance Method Summary

Text - Inherited

#<<

Appends text to this text node.

#<=>

other a String or a Text returns the result of (to_s <=> arg.to_s).

#clone, #doctype, #indent_text, #inspect, #node_type,
#to_s

Returns the string value of this text node.

#wrap,
#write

DEPRECATED See Formatters

#write_with_substitution

Writes out text, substituting special characters beforehand.

#xpath

FIXME This probably won't work properly.

#clear_cache

Child - Inherited

#bytes

This doesn't yet handle encodings.

#document
Returns

the document this child belongs to, or nil if this child belongs to no document.

#remove

Removes this child from the parent.

#replace_with

Replaces this object with another object.

Node - Included

#each_recursive

Visit all subnodes of self recursively.

#find_first_recursive

Find (and return) first subnode (recursively) for which the block evaluates to true.

#indent,
#index_in_parent

Returns the position that self holds in its parent's array, indexed from 1.

#next_sibling_node, #previous_sibling_node,
#to_s
indent

Constructor Details

.new(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 )
[ GitHub ]

  
# 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

#clone

Make a copy of this object

Examples

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

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

def clone
  CData.new self
end

#to_s

Returns the content of this CData object

Examples

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

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

def to_s
  @string
end

#value

[ GitHub ]

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

def value
  @string
end

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

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

  
# 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