### Home Classes Methods

### In Files

- lib/xmpp4r/roster/iq/roster.rb

### Parent

Jabber::XMPPElement

### Methods

- ::new
- #ask
- #ask=
- #groups
- #groups=
- #iname
- #iname=
- #jid
- #jid=
- #subscription
- #subscription=

### Files

- CHANGELOG
- COPYING
- LICENSE
- README.rdoc
- README_ruby19.txt

### Class/Module Index

Quicksearch

- Jabber
- Jabber::ArgumentError
- Jabber::Bytestreams
- Jabber::Bytestreams::IBB
- Jabber::Bytestreams::IBBInitiator
- Jabber::Bytestreams::IBBQueueItem
- Jabber::Bytestreams::IBBTarget
- Jabber::Bytestreams::IqQueryBytestreams
- Jabber::Bytestreams::IqSi
- Jabber::Bytestreams::IqSiFile
- Jabber::Bytestreams::IqSiFileRange
- Jabber::Bytestreams::SOCKS5Bytestreams
- Jabber::Bytestreams::SOCKS5BytestreamsInitiator
- Jabber::Bytestreams::SOCKS5BytestreamsPeer
- Jabber::Bytestreams::SOCKS5BytestreamsServer
- Jabber::Bytestreams::SOCKS5BytestreamsServerStreamHost
- Jabber::Bytestreams::SOCKS5BytestreamsTarget
- Jabber::Bytestreams::SOCKS5Socket
- Jabber::Bytestreams::StreamHost
- Jabber::Bytestreams::StreamHostUsed
- Jabber::Callback
- Jabber::CallbackList
- Jabber::Caps
- Jabber::Caps::C
- Jabber::Caps::Helper
- Jabber::Client
- Jabber::ClientAuthenticationFailure
- Jabber::Command
- Jabber::Command::IqCommand
- Jabber::Command::Responder
- Jabber::Component
- Jabber::ComponentAuthenticationFailure
- Jabber::Connection
- Jabber::Connection::SSLSocketUTF8
- Jabber::Dataforms
- Jabber::Dataforms::XData
- Jabber::Dataforms::XDataField
- Jabber::Dataforms::XDataInstructions
- Jabber::Dataforms::XDataReported
- Jabber::Dataforms::XDataTitle
- Jabber::Delay
- Jabber::Delay::XDelay
- Jabber::Discovery
- Jabber::Discovery::Feature
- Jabber::Discovery::Helper
- Jabber::Discovery::Identity
- Jabber::Discovery::IqQueryDiscoInfo
- Jabber::Discovery::IqQueryDiscoItems
- Jabber::Discovery::Item
- Jabber::Discovery::Responder
- Jabber::EntityTime
- Jabber::EntityTime::IqTime
- Jabber::EntityTime::Responder
- Jabber::ErrorResponse
- Jabber::FeatureNegotiation
- Jabber::FeatureNegotiation::IqFeature
- Jabber::FileTransfer
- Jabber::FileTransfer::FileSource
- Jabber::FileTransfer::Helper
- Jabber::FileTransfer::TransferSource
- Jabber::Framework
- Jabber::Framework::Base
- Jabber::Framework::Bot
- Jabber::HTTPBinding
- Jabber::HTTPBinding::Client
- Jabber::IdGenerator
- Jabber::InvalidChatState
- Jabber::Iq
- Jabber::IqQuery
- Jabber::JID
- Jabber::JabberError
- Jabber::LastActivity
- Jabber::LastActivity::Helper
- Jabber::LastActivity::IqQueryLastActivity
- Jabber::MUC
- Jabber::MUC::IqQueryMUCAdmin
- Jabber::MUC::IqQueryMUCAdminItem
- Jabber::MUC::IqQueryMUCOwner
- Jabber::MUC::MUCBrowser
- Jabber::MUC::MUCClient
- Jabber::MUC::SimpleMUCClient
- Jabber::MUC::UserItem
- Jabber::MUC::XMUC
- Jabber::MUC::XMUCUser
- Jabber::MUC::XMUCUserInvite
- Jabber::MUC::XMUCUserItem
- Jabber::Message
- Jabber::NoNameXmlnsRegistered
- Jabber::NotConnected
- Jabber::Observable
- Jabber::Observable::Contact
- Jabber::Observable::PubSub
- Jabber::Observable::PubSub::AlreadySet
- Jabber::Observable::PubSub::NoService
- Jabber::Observable::Subscriptions
- Jabber::Presence
- Jabber::PubSub
- Jabber::PubSub::Configuration
- Jabber::PubSub::Event
- Jabber::PubSub::EventItem
- Jabber::PubSub::EventItems
- Jabber::PubSub::IqPubSub
- Jabber::PubSub::IqPubSubOwner
- Jabber::PubSub::Item
- Jabber::PubSub::Items
- Jabber::PubSub::NodeBrowser
- Jabber::PubSub::NodeConfig
- Jabber::PubSub::NodeHelper
- Jabber::PubSub::OAuthPubSubStreamHelper
- Jabber::PubSub::OAuthServiceHelper
- Jabber::PubSub::OwnerNodeConfig
- Jabber::PubSub::Publish
- Jabber::PubSub::Retract
- Jabber::PubSub::ServiceHelper
- Jabber::PubSub::Subscription
- Jabber::PubSub::SubscriptionConfig
- Jabber::PubSub::Unsubscribe
- Jabber::RPC
- Jabber::RPC::Client
- Jabber::RPC::IqQueryRPC
- Jabber::RPC::Server
- Jabber::Reliable
- Jabber::Reliable::Connection
- Jabber::Reliable::Listener
- Jabber::Roster
- Jabber::Roster::Helper
- Jabber::Roster::Helper::RosterItem
- Jabber::Roster::IqQueryRoster
- Jabber::Roster::RosterItem
- Jabber::Roster::RosterX
- Jabber::Roster::RosterXItem
- Jabber::Roster::XRoster
- Jabber::Roster::XRosterItem
- Jabber::SASL
- Jabber::SASL::Anonymous
- Jabber::SASL::Base
- Jabber::SASL::DigestMD5
- Jabber::SASL::Plain
- Jabber::SOCKS5Error
- Jabber::Semaphore
- Jabber::ServerDisconnected
- Jabber::Stream
- Jabber::Stream::ThreadBlock
- Jabber::StreamParser
- Jabber::Test
- Jabber::Test::ListenerMocker
- Jabber::UserLocation
- Jabber::UserLocation::Helper
- Jabber::UserLocation::Location
- Jabber::UserTune
- Jabber::UserTune::Helper
- Jabber::UserTune::Tune
- Jabber::Vcard
- Jabber::Vcard::Helper
- Jabber::Vcard::IqVcard
- Jabber::Version
- Jabber::Version::IqQueryVersion
- Jabber::Version::Responder
- Jabber::Version::SimpleResponder
- Jabber::X
- Jabber::XHTML
- Jabber::XHTML::Body
- Jabber::XHTML::HTML
- Jabber::XMPPElement
- Jabber::XMPPStanza
- Jabber::XParent
- REXML
- REXML::Element
- REXML::IOSource
- XMLRPC
- XMLRPC::Create
- Base64
- ObservableThing
- QObserver
- ThreadStore

No matching classes.

# Jabber::Roster::RosterItem

Class containing the <item/> elements of the roster

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.

### Public Class Methods

new(jid=nil, iname=nil, subscription=nil, ask=nil) click to toggle source

Construct a new roster item

jid

JID

  Jabber ID

iname

String

  Name in the roster

subscription

Symbol

  Type of subscription (see RosterItem#subscription=)

ask

Symbol

  or [Nil] Can be :subscribe

    # File lib/xmpp4r/roster/iq/roster.rb, line 95
    def initialize(jid=nil, iname=nil, subscription=nil, ask=nil)
      super()
      self.jid = jid
      self.iname = iname
      self.subscription = subscription
      self.ask = ask
    end

### Public Instance Methods

ask() click to toggle source

Get if asking for subscription

result

Symbol

  nil or :subscribe

    # File lib/xmpp4r/roster/iq/roster.rb, line 170
    def ask
      case attributes['ask']
        when 'subscribe' then :subscribe
        else nil
      end
    end

ask=(val) click to toggle source

Set if asking for subscription

val

Symbol

  nil or :subscribe

    # File lib/xmpp4r/roster/iq/roster.rb, line 180
    def ask=(val)
      case val
        when :subscribe then attributes['ask'] = 'subscribe'
        else attributes['ask'] = nil
      end
    end

groups() click to toggle source

Get groups the item belongs to

result

Array

  of [String] The groups

    # File lib/xmpp4r/roster/iq/roster.rb, line 190
    def groups
      result = []
      each_element('group') { |group|
        result.push(group.text)
      }
      result.uniq
    end

groups=(ary) click to toggle source

Set groups the item belongs to, deletes old groups first.

See JEP 0083 for nested groups

ary

Array

  New groups, duplicate values will be removed

    # File lib/xmpp4r/roster/iq/roster.rb, line 204
    def groups=(ary)
      # Delete old group elements
      delete_elements('group')

      # Add new group elements
      ary.uniq.each { |group|
        add_element('group').text = group
      }
    end

iname() click to toggle source

Get name of roster item

names can be set by the roster's owner himself

return

String

    # File lib/xmpp4r/roster/iq/roster.rb, line 108
    def iname
      attributes['name']
    end

iname=(val) click to toggle source

Set name of roster item

val

String

  Name for this item

    # File lib/xmpp4r/roster/iq/roster.rb, line 115
    def iname=(val)
      attributes['name'] = val
    end

jid() click to toggle source

Get JID of roster item Resource of the JID will not be stripped

return

JID

    # File lib/xmpp4r/roster/iq/roster.rb, line 123
    def jid
      (a = attributes['jid']) ? JID.new(a) : nil
    end

jid=(val) click to toggle source

Set JID of roster item

val

JID

  or nil

    # File lib/xmpp4r/roster/iq/roster.rb, line 130
    def jid=(val)
      attributes['jid'] = val.nil? ? nil : val.to_s
    end

subscription() click to toggle source

Get subscription type of roster item

result

Symbol

  or [Nil] The following values are valid according to RFC3921:

- :both

- :from

- :none

- :remove

- :to

    # File lib/xmpp4r/roster/iq/roster.rb, line 142
    def subscription
      case attributes['subscription']
        when 'both' then :both
        when 'from' then :from
        when 'none' then :none
        when 'remove' then :remove
        when 'to' then :to
        else nil
      end
    end

subscription=(val) click to toggle source

Set subscription type of roster item

val

Symbol

  or [Nil] See subscription for possible Symbols

    # File lib/xmpp4r/roster/iq/roster.rb, line 156
    def subscription=(val)
      case val
        when :both then attributes['subscription'] = 'both'
        when :from then attributes['subscription'] = 'from'
        when :none then attributes['subscription'] = 'none'
        when :remove then attributes['subscription'] = 'remove'
        when :to then attributes['subscription'] = 'to'
        else attributes['subscription'] = nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.