Class: Jabber::PubSub::Subscription

Inherits:
XMPPElement show all
Defined in:
lib/xmpp4r/pubsub/children/subscription.rb

Overview

Subscription

Instance Method Summary collapse

Methods inherited from XMPPElement

class_for_name_xmlns, #clone, force_xmlns, force_xmlns?, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=

Methods inherited from REXML::Element

#==, #delete_elements, #each_elements, #first_element, #first_element_content, #first_element_text, #import, import, #replace_element_content, #replace_element_text, #typed_add

Constructor Details

#initialize(myjid = nil, mynode = nil, mysubid = nil, mysubscription = nil) ⇒ Subscription

Returns a new instance of Subscription.



13
14
15
16
17
18
19
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 13

def initialize(myjid=nil,mynode=nil,mysubid=nil,mysubscription=nil)
  super()
  jid = myjid
  node =  mynode
  subid =  mysubid
  state = mysubscription
end

Instance Method Details

#jidObject



20
21
22
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 20

def jid
  (a = attribute('jid')).nil? ? a : JID.new(a.value)
end

#jid=(myjid) ⇒ Object



23
24
25
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 23

def jid=(myjid)
  add_attribute('jid', myjid ? myjid.to_s : nil)
end

#need_approval?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 57

def need_approval?
  state == :pending
end

#nodeObject



27
28
29
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 27

def node
  attributes['node']
end

#node=(mynode) ⇒ Object



30
31
32
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 30

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

#stateObject Also known as: subscription



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 41

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

#state=(mystate) ⇒ Object



52
53
54
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 52

def state=(mystate)
  attributes['subscription'] = mystate
end

#subidObject



34
35
36
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 34

def subid
  attributes['subid']
end

#subid=(mysubid) ⇒ Object



37
38
39
# File 'lib/xmpp4r/pubsub/children/subscription.rb', line 37

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