Class Jabber::JID
In: lib/xmpp4r/jid.rb
Parent: Object
X XDelay XMuc XRoster XMucUser REXML::Element XRosterItem IqQuery XMLStanza IqVcard DiscoIdentity XMucUserItem DiscoItem Error RosterItem DiscoFeature IqQueryRoster IqQueryVersion IqQueryDiscoItems IqQueryDiscoInfo Message Presence Iq Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure RosterItem Stream StreamParser Roster Vcard Version lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/iq/query/roster.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/iq/query/version.rb lib/xmpp4r/connection.rb lib/xmpp4r/x/mucuseritem.rb lib/xmpp4r/x/roster.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/iq/query.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/x/delay.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/x/muc.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/iq/vcard.rb lib/xmpp4r/iq/query/discoinfo.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/message.rb lib/xmpp4r/iq/query/discoitems.rb lib/xmpp4r/presence.rb lib/xmpp4r/helpers/roster.rb lib/xmpp4r/helpers/vcard.rb lib/xmpp4r/helpers/version.rb Helpers Jabber Module: Jabber

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, …

Methods

<=>   eql?   hash   new   strip   strip!   to_s  

Included Modules

Comparable

Attributes

domain  [R] 
node  [R] 
resource  [R] 

Public Class methods

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

[Source]

    # File lib/xmpp4r/jid.rb, line 19
19:     def initialize(node = nil, domain = nil, resource = nil)
20:       if node.kind_of? JID
21:         @node = node.node
22:         @domain = node.domain
23:         @resource = node.resource
24:       else
25:         @resource = resource
26:         @domain = domain
27:         @node = node
28:         if domain.nil?
29:           if not node.nil?
30:             if node.include?('@')
31:               @node, @domain = node.split('@',2)
32:               if @domain.include?('/')
33:                 @domain, @resource = @domain.split('/',2)
34:               end
35:             elsif node.include?('/')
36:               @domain, @resource = @node.split('/',2)
37:             else
38:               @domain = node
39:               @node = nil
40:             end
41:           end
42:         end
43:       end
44:     end

Public Instance methods

Compare two JIDs, helpful for sorting etc.

String representations are compared, see JID#to_s

[Source]

    # File lib/xmpp4r/jid.rb, line 96
96:     def <=>(o)
97:       to_s <=> o.to_s
98:     end

Ccompare to another JID

String representations are compared, see JID#to_s

[Source]

    # File lib/xmpp4r/jid.rb, line 87
87:     def eql?(o)
88:       to_s.eql?(o.to_s)
89:     end

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

[Source]

    # File lib/xmpp4r/jid.rb, line 79
79:     def hash
80:       return to_s.hash
81:     end

Returns a new JID with resource removed.

return:[JID]

[Source]

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

Remove the resource of this object

return:[JID] self

[Source]

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

Returns a string representation of the JID

  • ""
  • "domain"
  • "node@domain"
  • "domain/resource"
  • "node@domain/resource"

[Source]

    # File lib/xmpp4r/jid.rb, line 53
53:     def to_s
54:       s = ''
55:       s = "#{@node}@" if not @node.nil?
56:       s += @domain if not @domain.nil?
57:       s += "/#{@resource}" if not @resource.nil?
58:       return s
59:     end

[Validate]