Class: Jabber::X
- Inherits:
-
REXML::Element
- Object
- REXML::Element
- Jabber::X
- Defined in:
- lib/xmpp4r/x.rb
Overview
A class used to build/parse <x/> elements
These elements may occur as “attachments” in [Message] and [Presence] stanzas
Direct Known Subclasses
Dataforms::XData, Delay::XDelay, MUC::XMUC, MUC::XMUCUser, Roster::XRoster
Constant Summary collapse
- @@namespace_classes =
{}
Class Method Summary collapse
-
.add_namespaceclass(ns, xclass) ⇒ Object
- Add a class by namespace for automatic X conversion (see X.import) ns
- String
- Namespace (e.g. ‘jabber:x:delay’) xclass
- X
-
x class derived from X.
-
.import(element) ⇒ Object
- Create a new [X] from an XML-Element element
- REXML::Element
-
to import, will be automatically converted if namespace appropriate.
Instance Method Summary collapse
-
#initialize ⇒ X
constructor
Initialize a <x/> element.
Methods inherited from REXML::Element
#delete_elements, #first_element, #first_element_text, #import, #replace_element_text, #typed_add
Constructor Details
#initialize ⇒ X
Initialize a <x/> element
Does nothing more than setting the element’s name to ‘x’
20 21 22 |
# File 'lib/xmpp4r/x.rb', line 20 def initialize super("x") end |
Class Method Details
.add_namespaceclass(ns, xclass) ⇒ Object
Add a class by namespace for automatic X conversion (see X.import)
- ns
- String
-
Namespace (e.g. ‘jabber:x:delay’)
- xclass
- X
-
x class derived from X
39 40 41 |
# File 'lib/xmpp4r/x.rb', line 39 def X.add_namespaceclass(ns, xclass) @@namespace_classes[ns] = xclass end |
.import(element) ⇒ Object
Create a new [X] from an XML-Element
- element
- REXML::Element
-
to import, will be automatically converted if namespace appropriate
27 28 29 30 31 32 33 |
# File 'lib/xmpp4r/x.rb', line 27 def X.import(element) if @@namespace_classes.has_key?(element.namespace) @@namespace_classes[element.namespace]::new.import(element) else X::new.import(element) end end |