Class: Blather::Stanza::PubSub::Retract
- Inherits:
-
Blather::Stanza::PubSub
- Object
- Niceogiri::XML::Node
- XMPPNode
- Blather::Stanza
- Iq
- Blather::Stanza::PubSub
- Blather::Stanza::PubSub::Retract
- Includes:
- Enumerable
- Defined in:
- lib/blather/stanza/pubsub/retract.rb
Overview
# PubSub Retract Stanza
[XEP-0060 Section 7.2 - Delete an Item from a Node](xmpp.org/extensions/xep-0060.html#publisher-delete)
Constant Summary
Constants inherited from Iq
Constants inherited from XMPPNode
Instance Attribute Summary
Attributes inherited from Blather::Stanza
Class Method Summary collapse
-
.new(host = nil, node = nil, type = :set, retractions = []) ⇒ Object
Createa new Retraction stanza.
Instance Method Summary collapse
-
#each {|id| ... } ⇒ Object
Iterate over each retraction ID.
-
#node ⇒ String
Get the name of the node to retract from.
-
#node=(node) ⇒ Object
Set the name of the node to retract from.
-
#retract ⇒ Blather::XMPPNode
Get or create the actual retract node.
-
#retractions ⇒ Array<String>
Get the list of item IDs to retract.
-
#retractions=(retractions = []) ⇒ Object
Set the retraction ids.
-
#size ⇒ Fixnum
The size of the retractions array.
Methods inherited from Blather::Stanza::PubSub
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(host = nil, node = nil, type = :set, retractions = []) ⇒ Object
Createa new Retraction stanza
22 23 24 25 26 27 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 22 def self.new(host = nil, node = nil, type = :set, retractions = []) new_node = super(type, host) new_node.node = node new_node.retractions = retractions new_node end |
Instance Method Details
#each {|id| ... } ⇒ Object
Iterate over each retraction ID
78 79 80 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 78 def each(&block) retractions.each &block end |
#node ⇒ String
Get the name of the node to retract from
32 33 34 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 32 def node retract[:node] end |
#node=(node) ⇒ Object
Set the name of the node to retract from
39 40 41 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 39 def node=(node) retract[:node] = node end |
#retract ⇒ Blather::XMPPNode
Get or create the actual retract node
46 47 48 49 50 51 52 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 46 def retract unless retract = pubsub.find_first('ns:retract', :ns => self.class.registered_ns) self.pubsub << (retract = XMPPNode.new('retract', self.document)) retract.namespace = self.pubsub.namespace end retract end |
#retractions ⇒ Array<String>
Get the list of item IDs to retract
69 70 71 72 73 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 69 def retractions retract.find('ns:item', :ns => self.class.registered_ns).map do |i| i[:id] end end |
#retractions=(id) ⇒ Object #retractions=(ids) ⇒ Object
Set the retraction ids
60 61 62 63 64 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 60 def retractions=(retractions = []) [retractions].flatten.each do |id| self.retract << PubSubItem.new(id, nil, self.document) end end |
#size ⇒ Fixnum
The size of the retractions array
85 86 87 |
# File 'lib/blather/stanza/pubsub/retract.rb', line 85 def size retractions.size end |