Class containing an <item/> element
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.
This is all a bit analoguous to Jabber::RosterItem, used by Jabber::IqQueryRoster. But this class lacks the subscription and ask attributes.
Get action for this roster item
:add
:modify
:delete
(defaults to :add according to JEP-0144)
# File lib/xmpp4r/roster/x/roster.rb, line 87 def action case attributes['action'] when 'modify' then :modify when 'delete' then :delete else :add end end
Set action for this roster item (see action)
# File lib/xmpp4r/roster/x/roster.rb, line 98 def action=(a) case a when :modify then attributes['action'] = 'modify' when :delete then attributes['action'] = 'delete' else attributes['action'] = 'add' end end
Get groups the item belongs to
of [String] The groups
# File lib/xmpp4r/roster/x/roster.rb, line 109 def groups result = [] each_element('group') { |group| result.push(group.text) } result 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/x/roster.rb, line 123 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/x/roster.rb, line 55 def iname attributes['name'] end
Set name of roster item
Name for this item
# File lib/xmpp4r/roster/x/roster.rb, line 62 def iname=(val) attributes['name'] = val end