Class

REXML::Child

Inheritance
< Object
Included Modules
Node

A Child object is something contained by a parent, and this class contains methods to support that. Most user code will not use this class directly.

Attributes

Name Visibility R/W Description
parent public R

Aliases

Method Alias Description
next_sibling_node → next_sibling
previous_sibling_node → previous_sibling

Methods

Class

Visibility Signature
public new ( parent = nil )

Instance

Visibility Signature
public bytes ()
public document ()
public next_sibling= ( other )
public parent= ( other )
public previous_sibling= (other)
public remove ()
public replace_with ( child )

Class Method Detail

new( parent = nil )

Constructor. Any inheritors of this class should call super to make sure this method is called.

parent:if supplied, the parent of this child will be set to the supplied value, and self will be added to the parent

Instance Method Detail

bytes()

This doesn‘t yet handle encodings

document()

Returns:the document this child belongs to, or nil if this child

belongs to no document

next_sibling=( other )

Sets the next sibling of this child. This can be used to insert a child after some other child.

 a = Element.new("a")
 b = a.add_element("b")
 c = Element.new("c")
 b.next_sibling = c
 # => <a><b/><c/></a>

parent=( other )

Sets the parent of this child to the supplied argument.

other:Must be a Parent object. If this object is the same object as the existing parent of this child, no action is taken. Otherwise, this child is removed from the current parent (if one exists), and is added to the new parent.
Returns:The parent added

previous_sibling=(other)

Sets the previous sibling of this child. This can be used to insert a child before some other child.

 a = Element.new("a")
 b = a.add_element("b")
 c = Element.new("c")
 b.previous_sibling = c
 # => <a><b/><c/></a>

remove()

Removes this child from the parent.

Returns:self

replace_with( child )

Replaces this object with another object. Basically, calls Parent.replace_child

Returns:self