Class: Jabber::MUC::XMUCUserItem

Inherits:
REXML::Element show all
Defined in:
lib/xmpp4r/muc/x/mucuseritem.rb

Instance Method Summary collapse

Methods inherited from REXML::Element

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

Constructor Details

#initialize(affiliation = nil, role = nil, jid = nil) ⇒ XMUCUserItem

Returns a new instance of XMUCUserItem



8
9
10
11
12
13
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 8

def initialize(affiliation=nil, role=nil, jid=nil)
  super('item')
  set_affiliation(affiliation)
  set_role(role)
  set_jid(jid)
end

Instance Method Details

#actorsObject



125
126
127
128
129
130
131
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 125

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

#actors=(a) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 133

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

#affiliationObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 15

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



26
27
28
29
30
31
32
33
34
35
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 26

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



109
110
111
112
113
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 109

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

#continue=(c) ⇒ Object



115
116
117
118
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 115

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

#jidObject



42
43
44
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 42

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

#jid=(j) ⇒ Object



46
47
48
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 46

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

#nickObject



55
56
57
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 55

def nick
  attributes['nick']
end

#nick=(n) ⇒ Object



59
60
61
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 59

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

#reasonObject



93
94
95
96
97
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 93

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

#reason=(s) ⇒ Object



99
100
101
102
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 99

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

#roleObject



68
69
70
71
72
73
74
75
76
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 68

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



78
79
80
81
82
83
84
85
86
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 78

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



141
142
143
144
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 141

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

#set_affiliation(v) ⇒ Object



37
38
39
40
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 37

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

#set_continue(c) ⇒ Object



120
121
122
123
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 120

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

#set_jid(j) ⇒ Object



50
51
52
53
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 50

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

#set_nick(n) ⇒ Object



63
64
65
66
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 63

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

#set_reason(s) ⇒ Object



104
105
106
107
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 104

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

#set_role(r) ⇒ Object



88
89
90
91
# File 'lib/xmpp4r/muc/x/mucuseritem.rb', line 88

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