Class: Blather::Stanza::Iq::Roster::RosterItem
- Inherits:
-
XMPPNode
- Object
- Nokogiri::XML::Node
- XMPPNode
- Blather::Stanza::Iq::Roster::RosterItem
- Defined in:
- lib/blather/stanza/iq/roster.rb
Constant Summary
Constants inherited from XMPPNode
Class Method Summary collapse
-
.new(jid = nil, name = nil, subscription = nil, ask = nil) ⇒ Object
- jid
-
may be either a JID or XMPPNode.
Instance Method Summary collapse
-
#groups ⇒ Object
The groups roster item belongs to.
-
#groups=(new_groups) ⇒ Object
Set the roster item’s groups must be an array.
-
#jid ⇒ Object
Roster item’s JID.
-
#to_stanza ⇒ Object
Convert the roster item to a proper stanza all wrapped up This facilitates new subscriptions.
Methods inherited from XMPPNode
attribute_accessor, attribute_reader, attribute_writer, class_from_registration, content_attr_accessor, content_attr_reader, content_attr_writer, #content_from, import, #inherit, #inherit_attrs, #namespace=, #namespace_href, #nokogiri_namespace=, register, #remove_child, #remove_children, #set_content_for
Methods inherited from Nokogiri::XML::Node
#[]=, #attr_set, #find_first, #nokogiri_xpath, #xpath
Class Method Details
.new(jid = nil, name = nil, subscription = nil, ask = nil) ⇒ Object
- jid
-
may be either a JID or XMPPNode.
- name
-
name alias of the given JID
- subscription
-
subscription type
- ask
-
ask subscription sub-state
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/blather/stanza/iq/roster.rb', line 40 def self.new(jid = nil, name = nil, subscription = nil, ask = nil) new_node = super :item case jid when Nokogiri::XML::Node new_node.inherit jid when Hash new_node.jid = jid[:jid] new_node.name = jid[:name] new_node.subscription = jid[:subscription] new_node.ask = jid[:ask] else new_node.jid = jid new_node.name = name new_node.subscription = subscription new_node.ask = ask end new_node end |
Instance Method Details
#groups ⇒ Object
The groups roster item belongs to
73 74 75 |
# File 'lib/blather/stanza/iq/roster.rb', line 73 def groups find('child::*[local-name()="group"]').map { |g| g.content } end |
#groups=(new_groups) ⇒ Object
Set the roster item’s groups must be an array
80 81 82 83 84 85 86 87 88 |
# File 'lib/blather/stanza/iq/roster.rb', line 80 def groups=(new_groups) remove_children :group if new_groups new_groups.uniq.each do |g| self << (group = XMPPNode.new(:group, self.document)) group.content = g end end end |