Class: Jabber::MUC::UserItem

Inherits:
XMPPElement show all
Defined in:
lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb

Overview

Don’t use this. It is the base class (unifying shared attributes) of XMUCUserItem and IqQueryMUCAdminItem

Direct Known Subclasses

IqQueryMUCAdminItem, XMUCUserItem

Instance Method Summary collapse

Methods inherited from XMPPElement

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

Methods inherited from REXML::Element

#==, #delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text, #typed_add

Constructor Details

This class inherits a constructor from Jabber::XMPPElement

Instance Method Details

#actorsObject



121
122
123
124
125
126
127
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 121

def actors
  a = []
  each_element('actor') { |xe|
    a.push(JID.new(xe.attributes['jid']))
  }
  a
end

#actors=(a) ⇒ Object



129
130
131
132
133
134
135
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 129

def actors=(a)
  delete_elements('actor')
  a.each { |jid|
    e = add_element('actor')
    e.attributes['jid'] = jid.to_s
  }
end

#affiliationObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 11

def affiliation
  case attributes['affiliation']
    when 'admin' then :admin
    when 'member' then :member
    when 'none' then :none
    when 'outcast' then :outcast
    when 'owner' then :owner
    else nil
  end
end

#affiliation=(v) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 22

def affiliation=(v)
  case v
    when :admin then attributes['affiliation'] = 'admin'
    when :member then attributes['affiliation'] = 'member'
    when :none then attributes['affiliation'] = 'none'
    when :outcast then attributes['affiliation'] = 'outcast'
    when :owner then attributes['affiliation'] = 'owner'
    else attributes['affiliation'] = nil
  end
end

#continueObject



105
106
107
108
109
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 105

def continue
  c = nil
  each_element('continue') { |xe| c = xe }
  c.nil?
end

#continue=(c) ⇒ Object



111
112
113
114
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 111

def continue=(c)
  delete_elements('continue')
  add_element('continue') if c
end

#jidObject



38
39
40
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 38

def jid
  attributes['jid'].nil? ? nil : JID.new(attributes['jid'])
end

#jid=(j) ⇒ Object



42
43
44
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 42

def jid=(j)
  attributes['jid'] = j.nil? ? nil : j.to_s
end

#nickObject



51
52
53
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 51

def nick
  attributes['nick']
end

#nick=(n) ⇒ Object



55
56
57
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 55

def nick=(n)
  attributes['nick'] = n
end

#reasonObject



89
90
91
92
93
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 89

def reason
  text = nil
  each_element('reason') { |xe| text = xe.text }
  text
end

#reason=(s) ⇒ Object



95
96
97
98
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 95

def reason=(s)
  delete_elements('reasion')
  add_element('reason').text = s
end

#roleObject



64
65
66
67
68
69
70
71
72
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 64

def role
  case attributes['role']
    when 'moderator' then :moderator
    when 'none' then :none
    when 'participant' then :participant
    when 'visitor' then :visitor
    else nil
  end
end

#role=(r) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 74

def role=(r)
  case r
    when :moderator then attributes['role'] = 'moderator'
    when :none then attributes['role'] = 'none'
    when :participant then attributes['role'] = 'participant'
    when :visitor then attributes['role'] = 'visitor'
    else attributes['role'] = nil
  end
end

#set_actors(a) ⇒ Object



137
138
139
140
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 137

def set_actors(a)
  self.actors = a
  self
end

#set_affiliation(v) ⇒ Object



33
34
35
36
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 33

def set_affiliation(v)
  self.affiliation = v
  self
end

#set_continue(c) ⇒ Object



116
117
118
119
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 116

def set_continue(c)
  self.continue = c
  self
end

#set_jid(j) ⇒ Object



46
47
48
49
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 46

def set_jid(j)
  self.jid = j
  self
end

#set_nick(n) ⇒ Object



59
60
61
62
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 59

def set_nick(n)
  self.nick = n
  self
end

#set_reason(s) ⇒ Object



100
101
102
103
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 100

def set_reason(s)
  self.reason = s
  self
end

#set_role(r) ⇒ Object



84
85
86
87
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb', line 84

def set_role(r)
  self.role = r
  self
end