Class: Blather::Stanza::DiscoInfo

Inherits:
Disco show all
Defined in:
lib/blather/stanza/disco/disco_info.rb

Overview

# 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

Direct Known Subclasses

Capabilities

Defined Under Namespace

Classes: Feature, Identity

Constant Summary

Constant Summary

Constants inherited from Iq

Iq::VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Disco

#node, #node=

Methods inherited from Iq::Query

#inherit, #query

Methods inherited from Iq

#error?, #get?, import, #reply!, #result?, #set?, #type=

Methods inherited from Blather::Stanza

#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply, #reply!, #to, #to=, #type, #type=

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Class Method Details

+ (DiscoInfo) new(type = nil, node = nil, identities = [], features = [])

Create a new DiscoInfo stanza identities. these are passed directly to DiscoInfo::Identity.new features. these are passed directly to DiscoInfo::Feature.new



22
23
24
25
26
27
28
# 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

Instance Method Details

- (true, false) eql?(o, *fields)

Compare two DiscoInfo objects by name, type and category



65
66
67
# File 'lib/blather/stanza/disco/disco_info.rb', line 65

def eql?(o, *fields)
  super o, *(fields + [:identities, :features])
end

- (Object) features

List of feature objects



47
48
49
50
51
# 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

- (Object) features=(features)

Add an array of features



55
56
57
58
59
60
# 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

- (Object) identities

List of identity objects



31
32
33
34
35
# 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

- (Object) identities=(identities)

Add an array of identities



39
40
41
42
43
44
# 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