Class: Jabber::IqQuery

Inherits:
REXML::Element show all
Defined in:
lib/xmpp4r/query.rb

Overview

A class used to build/parse IQ Query requests/responses

Constant Summary collapse

@@namespace_classes =
{}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from REXML::Element

#delete_elements, #first_element, #first_element_text, #import, #replace_element_text, #typed_add

Constructor Details

#initializeIqQuery

Initialize a <query/> element

Does nothing more than setting the element's name to 'query'


18
19
20
# File 'lib/xmpp4r/query.rb', line 18

def initialize
  super("query")
end

Class Method Details

.add_namespaceclass(ns, queryclass) ⇒ Object

Add a class by namespace for automatic IqQuery conversion (see IqQuery.import)

ns
String

Namespace (e.g. 'jabber:iq:roster')

queryclass
IqQuery

Query class derived from IqQuery


37
38
39
# File 'lib/xmpp4r/query.rb', line 37

def IqQuery.add_namespaceclass(ns, queryclass)
  @@namespace_classes[ns] = queryclass
end

.import(element) ⇒ Object

Create a new [IqQuery] from iq.query

element
REXML::Element

to import, will be automatically converted if namespace appropriate


25
26
27
28
29
30
31
# File 'lib/xmpp4r/query.rb', line 25

def IqQuery.import(element)
  if @@namespace_classes.has_key?(element.namespace)
    @@namespace_classes[element.namespace]::new.import(element)
  else
    IqQuery::new.import(element)
  end
end