Class: Jabber::Discovery::IqQueryDiscoItems

Inherits:
IqQuery show all
Defined in:
lib/xmpp4r/discovery/iq/discoitems.rb

Overview

Class for handling Service Discovery queries, items (JEP 0030)

This <query/> may contain multiple Item elements, describing multiple services to be browsed by Jabber clients. These may then get further information about these items by querying IqQueryDiscoInfo and further sub-items by querying IqQueryDiscoItems.

Instance Method Summary collapse

Methods inherited from IqQuery

add_namespaceclass, import

Methods inherited from REXML::Element

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

Constructor Details

#initializeIqQueryDiscoItems

Create a new query with namespace jabber.org/protocol/disco#items


23
24
25
26
# File 'lib/xmpp4r/discovery/iq/discoitems.rb', line 23

def initialize
  super
  add_namespace('http://jabber.org/protocol/disco#items')
end

Instance Method Details

#nodeObject

Get the queried Service Discovery node or nil

A Service Discovery node is not a JID node, this may be a bit confusing. It's just to make Service Discovery browsing a bit more structured.


52
53
54
# File 'lib/xmpp4r/discovery/iq/discoitems.rb', line 52

def node
  attributes['node']
end

#node=(val) ⇒ Object

Get the queried Service Discovery node or nil


58
59
60
# File 'lib/xmpp4r/discovery/iq/discoitems.rb', line 58

def node=(val)
  attributes['node'] = val
end

#set_node(val) ⇒ Object

Get the queried Service Discovery node or nil (chaining-friendly)


65
66
67
68
# File 'lib/xmpp4r/discovery/iq/discoitems.rb', line 65

def set_node(val)
  self.node = val
  self
end

#typed_add(element) ⇒ Object

Add a children element

Converts <item/> elements to [Item]


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xmpp4r/discovery/iq/discoitems.rb', line 32

def typed_add(element)
  if element.kind_of?(REXML::Element)

    if element.name == 'item'
      super(Item::new.import(element))
    else
      super(element)
    end

  else
    super(element)
  end
end