class Blather::Stanza::DiscoInfo

# DiscoInfo Stanza

[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

new(type = nil, node = nil, identities = [], features = []) click to toggle source

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

Calls superclass method
# 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

eql?(o, *fields) click to toggle source

Compare two DiscoInfo objects by name, type and category @param [DiscoInfo] o the Identity object to compare against @return [true, false]

Calls superclass method Blather::Stanza::Disco#eql?
# File lib/blather/stanza/disco/disco_info.rb, line 65
def eql?(o, *fields)
  super o, *(fields + [:identities, :features])
end
features() click to toggle source

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
features=(features) click to toggle source

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
identities() click to toggle source

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
identities=(identities) click to toggle source

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