Class: Blather::Stanza::Iq::Roster

Inherits:
Query show all
Defined in:
lib/blather/stanza/iq/roster.rb

Overview

# Roster Stanza

[RFC 3921 Section 7 - Roster Management](xmpp.org/rfcs/rfc3921.html#roster)

Defined Under Namespace

Classes: RosterItem

Constant Summary

Constants inherited from Blather::Stanza::Iq

VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#query

Methods inherited from Blather::Stanza::Iq

#error?, #get?, import, #reply!, #result?, #set?, #type=

Methods inherited from Blather::Stanza

#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply, #reply!, #to, #to=, #type, #type=

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Class Method Details

.new(type = nil, item = nil) ⇒ Object

Create a new roster stanza and (optionally) load it with an item

Parameters:



17
18
19
20
21
# File 'lib/blather/stanza/iq/roster.rb', line 17

def self.new(type = nil, item = nil)
  node = super type
  node.query << item if item
  node
end

Instance Method Details

#inherit(node) ⇒ Object

Inherit the XMPPNode to create a proper Roster object. Creates RosterItem objects out of each roster item as well.

Parameters:



27
28
29
30
31
32
33
34
# File 'lib/blather/stanza/iq/roster.rb', line 27

def inherit(node)
  # remove the current set of nodes
  remove_children :item
  super
  # transmogrify nodes into RosterItems
  items.each { |i| query << RosterItem.new(i); i.remove }
  self
end

#itemsArray<Blather::Stanza::Iq::Roster::RosterItem>

The list of roster items



39
40
41
42
43
# File 'lib/blather/stanza/iq/roster.rb', line 39

def items
  query.find('//ns:item', :ns => self.class.registered_ns).map do |i|
    RosterItem.new i
  end
end