Class containing the <item/> elements of the roster
The 'name' attribute has been renamed to 'iname' here as 'name' is already used by REXML::Element for the element's name. It's still name='…' in XML.
Construct a new roster item
Name in the roster
Type of subscription (see #subscription=)
or [Nil] Can be :subscribe
# File lib/xmpp4r/roster/iq/roster.rb, line 95 def initialize(jid=nil, iname=nil, subscription=nil, ask=nil) super() self.jid = jid self.iname = iname self.subscription = subscription self.ask = ask end
Get if asking for subscription
nil or :subscribe
# File lib/xmpp4r/roster/iq/roster.rb, line 170 def ask case attributes['ask'] when 'subscribe' then :subscribe else nil end end
Set if asking for subscription
nil or :subscribe
# File lib/xmpp4r/roster/iq/roster.rb, line 180 def ask=(val) case val when :subscribe then attributes['ask'] = 'subscribe' else attributes['ask'] = nil end end
Get groups the item belongs to
of [String] The groups
# File lib/xmpp4r/roster/iq/roster.rb, line 190 def groups result = [] each_element('group') { |group| result.push(group.text) } result.uniq end
Set groups the item belongs to, deletes old groups first.
See JEP 0083 for nested groups
New groups, duplicate values will be removed
# File lib/xmpp4r/roster/iq/roster.rb, line 204 def groups=(ary) # Delete old group elements delete_elements('group') # Add new group elements ary.uniq.each { |group| add_element('group').text = group } end
Get name of roster item
names can be set by the roster's owner himself
# File lib/xmpp4r/roster/iq/roster.rb, line 108 def iname attributes['name'] end
Set name of roster item
Name for this item
# File lib/xmpp4r/roster/iq/roster.rb, line 115 def iname=(val) attributes['name'] = val end
Get subscription type of roster item
or [Nil] The following values are valid according to RFC3921:
:both
:from
:none
:remove
:to
# File lib/xmpp4r/roster/iq/roster.rb, line 142 def subscription case attributes['subscription'] when 'both' then :both when 'from' then :from when 'none' then :none when 'remove' then :remove when 'to' then :to else nil end end
Set subscription type of roster item
or [Nil] See subscription for possible Symbols
# File lib/xmpp4r/roster/iq/roster.rb, line 156 def subscription=(val) case val when :both then attributes['subscription'] = 'both' when :from then attributes['subscription'] = 'from' when :none then attributes['subscription'] = 'none' when :remove then attributes['subscription'] = 'remove' when :to then attributes['subscription'] = 'to' else attributes['subscription'] = nil end end