### Home Classes Methods

### In Files

- lib/xmpp4r/jid.rb

### Parent

Object

### Methods

- ::escape
- ::new
- #<=>
- #==
- #bare
- #bare!
- #bared?
- #domain
- #domain=
- #empty?
- #eql?
- #hash
- #node
- #node=
- #resource
- #resource=
- #strip
- #strip!
- #stripped?
- #to_s

### Included Modules

- Comparable

### 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::JID

The JID class represents a Jabber Identifier as described by RFC3920 section 3.1.

Note that you can use JIDs also for Sorting, Hash keys, ...

### Constants

PATTERN
USE_STRINGPREP

### Public Class Methods

escape(jid) click to toggle source

Escape JID

    # File lib/xmpp4r/jid.rb, line 152
    def JID::escape(jid)
      return jid.to_s.gsub('@', '%')
    end

new(node = "", domain = nil, resource = nil) click to toggle source

Create a new JID. If called as new('a@b/c'), parse the string and split (node, domain, resource)

    # File lib/xmpp4r/jid.rb, line 26
    def initialize(node = "", domain = nil, resource = nil)
      @resource = resource
      @domain = domain
      @node = node
      if @domain.nil? and @resource.nil? and @node
        @node, @domain, @resource = @node.to_s.scan(PATTERN).first
      end

      if USE_STRINGPREP
        @node = IDN::Stringprep.nodeprep(@node) if @node
        @domain = IDN::Stringprep.nameprep(@domain) if @domain
        @resource = IDN::Stringprep.resourceprep(@resource) if @resource
      else
        @node.downcase! if @node
        @domain.downcase! if @domain
      end

      raise ArgumentError, 'Node too long' if (@node || '').length > 1023
      raise ArgumentError, 'Domain too long' if (@domain || '').length > 1023
      raise ArgumentError, 'Resource too long' if (@resource || '').length > 1023
    end

### Public Instance Methods

<=>(o) click to toggle source

Compare two JIDs, helpful for sorting etc.

String representations are compared, see JID#to_s

    # File lib/xmpp4r/jid.rb, line 107
    def <=>(o)
      to_s <=> o.to_s
    end

==(o) click to toggle source

Ccompare to another JID

String representations are compared, see JID#to_s

    # File lib/xmpp4r/jid.rb, line 98
    def ==(o)
      to_s == o.to_s
    end

bare() click to toggle source
Alias for: strip
bare!() click to toggle source
Alias for: strip!
bared?() click to toggle source
Alias for: stripped?
domain() click to toggle source

Get the JID's domain

    # File lib/xmpp4r/jid.rb, line 125
    def domain
      return nil if @domain.empty?
      @domain
    end

domain=(v) click to toggle source

Set the JID's domain

    # File lib/xmpp4r/jid.rb, line 131
    def domain=(v)
      @domain = v.to_s
      if USE_STRINGPREP
        @domain = IDN::Stringprep.nodeprep(@domain)
      end
    end

empty?() click to toggle source

Test if jid is empty

    # File lib/xmpp4r/jid.rb, line 157
    def empty?
      to_s.empty?
    end

eql?(o) click to toggle source

Ccompare to another JID

String representations are compared, see JID#to_s

    # File lib/xmpp4r/jid.rb, line 90
    def eql?(o)
      to_s.eql?(o.to_s)
    end

hash() click to toggle source

Returns a hash value of the String representation (see JID#to_s)

    # File lib/xmpp4r/jid.rb, line 82
    def hash
      return to_s.hash
    end

node() click to toggle source

Get the JID's node

    # File lib/xmpp4r/jid.rb, line 112
    def node
      @node
    end

node=(v) click to toggle source

Set the JID's node

    # File lib/xmpp4r/jid.rb, line 117
    def node=(v)
      @node = v.to_s
      if USE_STRINGPREP
        @node = IDN::Stringprep.nodeprep(@node) if @node
      end
    end

resource() click to toggle source

Get the JID's resource

    # File lib/xmpp4r/jid.rb, line 139
    def resource
      @resource
    end

resource=(v) click to toggle source

Set the JID's resource

    # File lib/xmpp4r/jid.rb, line 144
    def resource=(v)
      @resource = v.to_s
      if USE_STRINGPREP
        @resource = IDN::Stringprep.nodeprep(@resource)
      end
    end

strip() click to toggle source

Returns a new JID with resource removed.

return

JID

    # File lib/xmpp4r/jid.rb, line 65
    def strip
      JID.new(@node, @domain)
    end

Also aliased as: bare
strip!() click to toggle source

Removes the resource (sets it to nil)

return

JID

  self

    # File lib/xmpp4r/jid.rb, line 73
    def strip!
      @resource = nil
      self
    end

Also aliased as: bare!
stripped?() click to toggle source

Test id jid is strepped

    # File lib/xmpp4r/jid.rb, line 162
    def stripped?
      @resource.nil?
    end

Also aliased as: bared?
to_s() click to toggle source

Returns a string representation of the JID

- ""

- "domain"

- "node@domain"

- "domain/resource"

- "node@domain/resource"

    # File lib/xmpp4r/jid.rb, line 55
    def to_s
      s = @domain
      s = "#{@node}@#{s}" if @node
      s += "/#{@resource}" if @resource
      return s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.