Sha256: 510b5060cf643af973085373cbe4038ef0a6181ff7b11dc82f67ff9d6d1f7bb0

Contents?: true

Size: 1.51 KB

Versions: 33

Compression:

Stored size: 1.51 KB

Contents

# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://home.gna.org/xmpp4r/

require 'xmpp4r/iq'

module Jabber
  module PubSub
    ##
    # Subscription
    class Subscription < XMPPElement
      name_xmlns 'subscription', NS_PUBSUB
      def initialize(myjid=nil,mynode=nil,mysubid=nil,mysubscription=nil)
        super()
        jid = myjid
        node =  mynode
        subid =  mysubid
        state = mysubscription
      end
      def jid
        (a = attribute('jid')).nil? ? a : JID.new(a.value)
      end
      def jid=(myjid)
        add_attribute('jid', myjid ? myjid.to_s : nil)
      end

      def node
        attributes['node']
      end
      def node=(mynode)
        attributes['node'] = mynode
      end

      def subid
        attributes['subid']
      end
      def subid=(mysubid)
        attributes['subid'] = mysubid
      end

      def state
          # each child of event
          # this should interate only one time
          case attributes['subscription']
              when 'none'      		then return :none
              when 'pending'   		then return :pending
              when 'subscribed'         then return :subscribed
              when 'unconfigured'       then return :unconfigured
              else return nil
          end
      end
      def state=(mystate)
        attributes['subscription'] = mystate
      end
      alias subscription state

      def need_approval?
        state == :pending
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 13 rubygems

Version Path
brontes3d-xmpp4r-0.4 lib/xmpp4r/pubsub/children/subscription.rb
bryanl-xmpp4r-0.3.2 lib/xmpp4r/pubsub/children/subscription.rb
edavey-xmpp4r-0.4.1 lib/xmpp4r/pubsub/children/subscription.rb
edavey-xmpp4r-0.4.2 lib/xmpp4r/pubsub/children/subscription.rb
edavey-xmpp4r-0.4 lib/xmpp4r/pubsub/children/subscription.rb
heipei-xmpp4r-0.3.2 lib/xmpp4r/pubsub/children/subscription.rb
ln-xmpp4r-0.5 lib/xmpp4r/pubsub/children/subscription.rb
mojodna-xmpp4r-0.4.0.2 lib/xmpp4r/pubsub/children/subscription.rb
mojodna-xmpp4r-0.4.0.3 lib/xmpp4r/pubsub/children/subscription.rb
seanohalpin-xmpp4r-0.4.1 lib/xmpp4r/pubsub/children/subscription.rb
xmpp4r-0.5.5 lib/xmpp4r/pubsub/children/subscription.rb
gmcmillan-xmpp4r-0.6.2 lib/xmpp4r/pubsub/children/subscription.rb
gmcmillan-xmpp4r-0.6.1 lib/xmpp4r/pubsub/children/subscription.rb
gmcmillan-xmpp4r-0.6 lib/xmpp4r/pubsub/children/subscription.rb
gmcmillan-xmpp4r-0.5 lib/xmpp4r/pubsub/children/subscription.rb
mad-p-xmpp4r-0.6.3 lib/xmpp4r/pubsub/children/subscription.rb
mad-p-xmpp4r-0.6.2 lib/xmpp4r/pubsub/children/subscription.rb
mad-p-xmpp4r-0.6.1 lib/xmpp4r/pubsub/children/subscription.rb
mad-p-xmpp4r-0.6.0 lib/xmpp4r/pubsub/children/subscription.rb
cerberus-0.8.0 lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/subscription.rb