Class Jabber::Protocol::ParsedXMLElement
In: lib/jabber4r/protocol.rb
Parent: Object

This class is constructed from XML data elements that are received from the Jabber service.

Methods
[]    add_attribute    add_child    append_data    consume_element    count    element_consumed?    method_missing    new    size    to_s   
Attributes
element_children  [R] 

A hash of ParsedXMLElement children

element_data  [R] 

The data <tag>data</tag> for a tag

element_parent  [R] 

The parent ParsedXMLElement

element_tag  [R] 

The <tag> as String

Classes and Modules
Class Jabber::Protocol::ParsedXMLElement::NilParsedXMLElement
Public Class methods
new(tag, parent=nil)

Construct an instance for the given tag

tag:[String] The tag
parent:[Jabber::Protocol::ParsedXMLElement = nil] The parent element
Public Instance methods
add_attribute(name, value)

Add the attribute to the element

  <tag name="value">data</tag>
name:[String] The attribute name
value:[String] The attribute value
return:[Jabber::Protocol::ParsedXMLElement] self for chaining
add_child(tag)

Factory to build a child element from this element with the given tag

tag:[String] The tag name
return:[Jabber::Protocol::ParsedXMLElement] The newly created child element
consume_element()

When an xml is received from the Jabber service and a ParsedXMLElement is created, it is propogated to all filters and listeners. Any one of those can consume the element to prevent its propogation to other filters or listeners. This method marks the element as consumed.

element_consumed?()

Checks if the element is consumed

return:[Boolean] True if the element is consumed
append_data(data)

Appends data to the element

data:[String] The data to append
return:[Jabber::Protocol::ParsedXMLElement] self for chaining
[](number)

Calls the parent’s element_children (hash) index off of this elements tag and gets the supplied index. In this sense it gets its sibling based on offset.

number:[Integer] The number of the sibling to get
return:[Jabber::Protocol::ParsedXMLElement] The sibling element
count()

Returns the count of siblings with this element’s tag

return:[Integer] The number of sibling elements
size()

see _count

method_missing(methId, *args)

Overrides to allow for directly accessing child elements and attributes. If prefaced by attr_ it looks for an attribute that matches or checks for a child with a tag that matches the method name. If no match occurs, it returns a NilParsedXMLElement (singleton) instance.

Example:<alpha number="1"><beta number="2">Beta Data</beta></alpha>
 element.element_tag #=> alpha
 element.attr_number #=> 1
 element.beta.element_data #=> Beta Data
to_s()

Returns the valid XML as a string

return:[String] XML string