Class: Blather::Stanza::PubSub::Publish
Constant Summary
Constants inherited
from Iq
Iq::VALID_TYPES
Constants inherited
from XMPPNode
XMPPNode::BASE_NAMES
Class Method Summary
collapse
Instance Method Summary
collapse
import, #inherit, #pubsub
Methods inherited from Iq
import, #type=
#as_error, attribute_helpers_for, #from, handler_list, next_id, register, #reply, #reply!, #to
Methods inherited from XMPPNode
attribute_accessor, attribute_reader, attribute_writer, class_from_registration, content_attr_accessor, content_attr_reader, content_attr_writer, #content_from, import, #inherit, #inherit_attrs, #namespace=, #namespace_href, #nokogiri_namespace=, register, #remove_child, #remove_children, #set_content_for, #to_stanza
#[]=, #attr_set, #find_first, #nokogiri_xpath, #xpath
Class Method Details
.new(host = nil, node = nil, type = :set, payload = nil) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 11
def self.new(host = nil, node = nil, type = :set, payload = nil)
new_node = super(type, host)
new_node.node = node
new_node.payload = payload if payload
new_node
end
|
Instance Method Details
#each(&block) ⇒ Object
47
48
49
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 47
def each(&block)
items.each &block
end
|
43
44
45
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 43
def items
publish.find('ns:item', :ns => self.class.registered_ns).map { |i| PubSubItem.new(nil,nil,self.document).inherit i }
end
|
27
28
29
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 27
def node
publish[:node]
end
|
#node=(node) ⇒ Object
31
32
33
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 31
def node=(node)
publish[:node] = node
end
|
#payload=(payload) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 18
def payload=(payload)
payload = case payload
when Hash then payload.to_a
when Array then payload.map { |v| [nil, v] }
else [[nil, payload.to_s]]
end
payload.each { |id,value| self.publish << PubSubItem.new(id, value, self.document) }
end
|
35
36
37
38
39
40
41
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 35
def publish
unless publish = pubsub.find_first('ns:publish', :ns => self.class.registered_ns)
self.pubsub << (publish = XMPPNode.new('publish', self.document))
publish.namespace = self.pubsub.namespace
end
publish
end
|
51
52
53
|
# File 'lib/blather/stanza/pubsub/publish.rb', line 51
def size
items.size
end
|