class Blather::Stanza::PubSubItem
# PubSubItem
Fragment
This fragment is found in many places throughout the pubsub spec This is a convenience class to attach methods to the node
Public Class Methods
new(id = nil, payload = nil, document = nil)
click to toggle source
Create a new PubSubItem
@param [String, nil] id the id of the stanza @param [#to_s, nil] payload the payload to attach to this item. @param [XML::Document, nil] document the document the node should be attached to. This should be the document of the parent PubSub
node.
Calls superclass method
# File lib/blather/stanza/pubsub.rb, line 74 def self.new(id = nil, payload = nil, document = nil) return id if id.class == self new_node = super 'item', document new_node.id = id new_node.payload = payload if payload new_node end
Public Instance Methods
id()
click to toggle source
Get the item's ID
@return [String, nil]
# File lib/blather/stanza/pubsub.rb, line 86 def id read_attr :id end
id=(id)
click to toggle source
Set the item's ID
@param [#to_s] id the new ID
# File lib/blather/stanza/pubsub.rb, line 93 def id=(id) write_attr :id, id end
payload()
click to toggle source
Get the item's payload
@return [String, nil]
# File lib/blather/stanza/pubsub.rb, line 102 def payload children.empty? ? nil : children.to_s end
payload=(payload)
click to toggle source
Set the item's payload
@param [String, XMPPNode
, nil] payload the payload
# File lib/blather/stanza/pubsub.rb, line 109 def payload=(payload) children.map &:remove return unless payload if payload.is_a?(String) self.content = payload else self << payload end end