Class: Blather::Stanza::DiscoInfo
- Inherits:
-
Disco
- Object
- Niceogiri::XML::Node
- XMPPNode
- Blather::Stanza
- Iq
- Iq::Query
- Disco
- Blather::Stanza::DiscoInfo
- 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
Defined Under Namespace
Constant Summary
Constants inherited from Iq
Constants inherited from XMPPNode
Instance Attribute Summary
Attributes inherited from Blather::Stanza
Class Method Summary collapse
-
.new(type = nil, node = nil, identities = [], features = []) ⇒ DiscoInfo
Create a new DiscoInfo stanza identities.
Instance Method Summary collapse
-
#eql?(o, *fields) ⇒ true, false
Compare two DiscoInfo objects by name, type and category.
-
#features ⇒ Object
List of feature objects.
-
#features=(features) ⇒ Object
Add an array of features.
-
#identities ⇒ Object
List of identity objects.
-
#identities=(identities) ⇒ Object
Add an array of identities.
Methods inherited from Disco
Methods inherited from Iq::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
.new(type = nil, node = nil, identities = [], features = []) ⇒ DiscoInfo
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
#eql?(o, *fields) ⇒ true, false
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 |
#features ⇒ Object
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 |
#features=(features) ⇒ Object
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 |
#identities ⇒ Object
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 |
#identities=(identities) ⇒ Object
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 |