Sha256: 3cfa2728586391d8625a8c1eb3cf48a54404c463419e6713f0bba7b017f991f1
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
module Blather class Stanza class Iq class Roster < Query register :roster, nil, 'jabber:iq:roster' def initialize(type = nil, item = nil) super(type) query << item if item end def inherit(node) items.each { |i| i.remove! } @items = nil super items.each { |i| query << RosterItem.new(i); i.remove! } @items = nil self end def items query.find('item')#.map { |g| RosterItem.new g } end class RosterItem < XMPPNode def initialize(jid = nil, name = nil, subscription = nil, ask = nil) super('item') if jid.is_a?(XML::Node) self.inherit jid else self.jid = jid self.name = name self.subscription = subscription self.ask = ask end end def jid (j = attributes['jid']) ? JID.new(j) : nil end def jid=(jid) attributes['jid'] = jid end def name attributes['name'] end def name=(name) attributes['name'] = name end def subscription attributes['subscription'].to_sym if attributes['subscription'] end def subscription=(subscription) attributes['subscription'] = subscription end def ask attributes['ask'].to_sym if attributes['ask'] end def ask=(ask) attributes['ask'] = ask end def groups @groups ||= find('group').map { |g| g.content } end def groups=(grps) find('group').each { |g| g.remove! } @groups = nil grps.uniq.each { |g| add_node XMPPNode.new('group', g.to_s) } if grps end def to_stanza Roster.new(:set, self) end end #RosterItem end #Roster end #Iq end #Stanza end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blather-0.2.1 | lib/blather/stanza/iq/roster.rb |