class Blather::Stanza::DiscoInfo
[XEP-0030 Disco
Info](xmpp.org/extensions/xep-0030.html#info)
Disco
Info node that provides or retreives information about a jabber entity
@handler :disco_info
Public Class Methods
Create a new DiscoInfo
stanza @param [:get, :set, :result, :error, nil] type the Iq
stanza type @param [String, nil] node the name of the node the info belongs to @param [Array<Array, DiscoInfo::Identity>, nil] identities a list of identities. these are passed directly to DiscoInfo::Identity.new
@param [Array<Array, DiscoInfo::Identity>, nil] features a list of features. these are passed directly to DiscoInfo::Feature.new
@return [DiscoInfo] a new DiscoInfo
stanza
# File lib/blather/stanza/disco/disco_info.rb, line 22 def self.new(type = nil, node = nil, identities = [], features = []) new_node = super type new_node.node = node new_node.identities = [identities] new_node.features = [features] new_node end
Public Instance Methods
Compare two DiscoInfo
objects by name, type and category @param [DiscoInfo] o the Identity
object to compare against @return [true, false]
Blather::Stanza::Disco#eql?
# File lib/blather/stanza/disco/disco_info.rb, line 65 def eql?(o, *fields) super o, *(fields + [:identities, :features]) end
List of feature objects
# File lib/blather/stanza/disco/disco_info.rb, line 47 def features query.find('//ns:feature', :ns => self.class.registered_ns).map do |f| Feature.new f end end
Add an array of features @param features the array of features, passed directly to Feature.new
# File lib/blather/stanza/disco/disco_info.rb, line 55 def features=(features) query.find('//ns:feature', :ns => self.class.registered_ns).each &:remove if features [features].flatten.each { |f| self.query << Feature.new(f) } end end
List of identity objects
# File lib/blather/stanza/disco/disco_info.rb, line 31 def identities query.find('//ns:identity', :ns => self.class.registered_ns).map do |i| Identity.new i end end
Add an array of identities @param identities the array of identities, passed directly to Identity.new
# File lib/blather/stanza/disco/disco_info.rb, line 39 def identities=(identities) query.find('//ns:identity', :ns => self.class.registered_ns).each &:remove if identities [identities].flatten.each { |i| self.query << Identity.new(i) } end end