Class: Jabber::MUC::XMUCUser

Inherits:
X show all
Defined in:
lib/xmpp4r/muc/x/muc.rb

Overview

Class for <x/> elements with namespace jabber.org/protocol/muc#user

See JEP-0058 for details

Instance Method Summary collapse

Methods inherited from X

add_namespaceclass, import

Methods inherited from REXML::Element

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

Constructor Details

#initializeXMUCUser

Initialize an <x/> element and set namespace to jabber.org/protocol/muc#user



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

def initialize
  super
  add_namespace('http://jabber.org/protocol/muc#user')
end

Instance Method Details

#itemsObject

Get all <item/> elements

result
Array

of [XMUCUserItem]



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

def items
  res = []
  each_element('item') { |item|
    res << item
  }
  res
end

#status_codeObject

Retrieve the three-digit code in <x xmlns='http://jabber.org/protocol/muc#user'><status code='...'/></x>

result
Fixnum

or nil



73
74
75
76
77
78
79
80
81
# File 'lib/xmpp4r/muc/x/muc.rb', line 73

def status_code
  e = nil
  each_element('status') { |xe| e = xe }
  if e and e.attributes['code'].size == 3 and e.attributes['code'].to_i != 0
    e.attributes['code'].to_i
  else
    nil
  end
end

#typed_add(element) ⇒ Object

Add a children element, will be imported to [XMUCUserItem] if name is “item”



59
60
61
62
63
64
65
66
67
# File 'lib/xmpp4r/muc/x/muc.rb', line 59

def typed_add(element)
  if element.kind_of?(REXML::Element) && (element.name == 'item')
    super(XMUCUserItem::new.import(element))
  elsif element.kind_of?(REXML::Element) && (element.name == 'invite')
    super(XMUCUserInvite::new.import(element))
  else
    super(element)
  end
end