class Jabber::Roster::IqQueryRoster

Class for handling roster updates

You must do 'client.send(Iq.new_rosterget)' or else you will have nothing to put in #receive_iq()

You must require 'xmpp4r/rosterquery' to use this class as its functionality is not needed for a working XMPP implementation. This will make [IqQuery] convert all Queries with namespace 'jabber:iq:roster' to [IqQueryRoster]

This <query/> contains multiple <item/> children. See RosterItem.

Public Instance Methods

[](jid) click to toggle source

Get roster item by JID

jid
JID

or [Nil]

result
RosterItem
# File lib/xmpp4r/roster/iq/roster.rb, line 38
def [](jid)
  each { |item|
    return(item) if item.jid == jid
  }
  nil
end
each() { |item| ... } click to toggle source

Iterate through all items

&block

Yield for every [RosterItem]

# File lib/xmpp4r/roster/iq/roster.rb, line 27
def each(&block)
  each_element { |item|
    # XPath won't work here as it's missing a prefix...
    yield(item) if item.kind_of?(RosterItem)
  }
end
inspect() click to toggle source

Output for ā€œpā€

JIDs of all contained [RosterItem] elements are joined with a comma

result
String
# File lib/xmpp4r/roster/iq/roster.rb, line 74
def inspect
  jids = to_a.collect { |item| item.jid.inspect }
  jids.join(', ')
end
receive_iq(iq, filter=true) click to toggle source

Update roster by <iq/> stanza (to be fed by an iq_callback)

iq
Iq

Containing new roster

filter
Boolean

If false import non-roster-like results too

# File lib/xmpp4r/roster/iq/roster.rb, line 61
def receive_iq(iq, filter=true)
  if filter && (((iq.type != :set) && (iq.type != :result)) || (iq.queryns != 'jabber:iq:roster'))
    return
  end

  import(iq.query)
end
to_a() click to toggle source

Get all items

result
Array

of [RosterItem]

# File lib/xmpp4r/roster/iq/roster.rb, line 48
def to_a
  a = []
  each { |item|
    a.push(item)
  }
  a
end