class Blather::Stanza::PubSub::Subscription
[XEP-0060 Section 8.8 Manage Subscriptions](xmpp.org/extensions/xep-0060.html#owner-subscriptions)
@handler :pubsub_subscription
Constants
- VALID_TYPES
@private
Public Class Methods
Create
a new subscription request node
@param [Blather::Stanza::Iq::VALID_TYPES] type the IQ type @param [String] host the host to send the request to @param [String] node the node to look for requests on @param [Blather::JID, to_s] jid the JID
of the subscriber @param [String] subid the subscription ID @param [VALID_TYPES] subscription the subscription type
Blather::Stanza::PubSub::new
# File lib/blather/stanza/pubsub/subscription.rb, line 24 def self.new(type = :result, host = nil, node = nil, jid = nil, subid = nil, subscription = nil) new_node = super(type, host) new_node.node = node new_node.jid = jid new_node.subid = subid new_node.subscription = subscription new_node end
Public Instance Methods
Get the JID
of the subscriber
@return [Blather::JID]
# File lib/blather/stanza/pubsub/subscription.rb, line 64 def jid JID.new(subscription_node[:jid]) end
Set the JID
of the subscriber
@param [Blather::JID, to_s] jid
# File lib/blather/stanza/pubsub/subscription.rb, line 71 def jid=(jid) subscription_node[:jid] = jid end
Get the name of the subscription node
@return [String]
# File lib/blather/stanza/pubsub/subscription.rb, line 78 def node subscription_node[:node] end
Set the name of the subscription node
@param [String] node
# File lib/blather/stanza/pubsub/subscription.rb, line 85 def node=(node) subscription_node[:node] = node end
Check if the type is none
@return [Boolean]
# File lib/blather/stanza/pubsub/subscription.rb, line 36 def none? self.subscription == :none end
Check if the type is pending
@return [Boolean]
# File lib/blather/stanza/pubsub/subscription.rb, line 43 def pending? self.subscription == :pending end
Get the ID of the subscription
@return [String]
# File lib/blather/stanza/pubsub/subscription.rb, line 92 def subid subscription_node[:subid] end
Set the ID of the subscription
@param [String] subid
# File lib/blather/stanza/pubsub/subscription.rb, line 99 def subid=(subid) subscription_node[:subid] = subid end
Check if the type is subscribed
@return [Boolean]
# File lib/blather/stanza/pubsub/subscription.rb, line 50 def subscribed? self.subscription == :subscribed end
Get the subscription type
@return [VALID_TYPES, nil]
# File lib/blather/stanza/pubsub/subscription.rb, line 106 def subscription s = subscription_node[:subscription] s.to_sym if s end
Set the subscription type
@param [VALID_TYPES, nil] subscription
# File lib/blather/stanza/pubsub/subscription.rb, line 114 def subscription=(subscription) if subscription && !VALID_TYPES.include?(subscription.to_sym) raise ArgumentError, "Invalid Type (#{type}), use: #{VALID_TYPES*' '}" end subscription_node[:subscription] = subscription end
Get or create the actual subscription node
@return [Blather::XMPPNode]
# File lib/blather/stanza/pubsub/subscription.rb, line 124 def subscription_node unless subscription = pubsub.find_first('ns:subscription', :ns => self.class.registered_ns) self.pubsub << (subscription = XMPPNode.new('subscription', self.document)) subscription.namespace = self.pubsub.namespace end subscription end
Check if the type is unconfigured
@return [Boolean]
# File lib/blather/stanza/pubsub/subscription.rb, line 57 def unconfigured? self.subscription == :unconfigured end