Class: Jabber::Discovery::IqQueryDiscoInfo

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

Overview

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

This <query/> may contain multiple Identity and Feature elements, describing the type and the supported namespaces of the service.

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

#initializeIqQueryDiscoInfo

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


21
22
23
24
# File 'lib/xmpp4r/discovery/iq/discoinfo.rb', line 21

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

Instance Method Details

#featuresObject

Get list of features

result
Array

of [String]


82
83
84
85
86
87
88
# File 'lib/xmpp4r/discovery/iq/discoinfo.rb', line 82

def features
  res = []
  each_element('feature') { |feature|
    res.push(feature.var)
  }
  res
end

#identityObject

Get the first identity child

result
Identity

75
76
77
# File 'lib/xmpp4r/discovery/iq/discoinfo.rb', line 75

def identity
  first_element('identity')
end

#nodeObject

Get the queried Service Discovery node or nil

See IqQueryDiscoItems#node for a small explanation of this.


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

def node
  attributes['node']
end

#node=(val) ⇒ Object

Get the queried Service Discovery node or nil

val
String

59
60
61
# File 'lib/xmpp4r/discovery/iq/discoinfo.rb', line 59

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

#set_node(val) ⇒ Object

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

val
String

67
68
69
70
# File 'lib/xmpp4r/discovery/iq/discoinfo.rb', line 67

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

#typed_add(element) ⇒ Object

Add a children element

Converts <identity/> elements to [Identity] and <feature/> elements to [Feature]


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

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

    if element.name == 'identity'
      super(Identity::new.import(element))
    elsif element.name == 'feature'
      super(Feature::new.import(element))
    else
      super(element)
    end

  else
    super(element)
  end
end