Class: XMPPSimple::Jid

Inherits:
Object
  • Object
show all
Defined in:
lib/xmpp_simple/jid.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, host = nil) ⇒ Jid

Returns a new instance of Jid.



5
6
7
8
9
10
11
12
13
# File 'lib/xmpp_simple/jid.rb', line 5

def initialize(username, host = nil)
  if username.to_s.include?('@')
    @username, @domain = username.split('@')
  else
    raise 'set either host or username@host' if host.nil?
    @username = username
    @domain = host
  end
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



3
4
5
# File 'lib/xmpp_simple/jid.rb', line 3

def domain
  @domain
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/xmpp_simple/jid.rb', line 3

def username
  @username
end

Instance Method Details

#to_sObject



15
16
17
# File 'lib/xmpp_simple/jid.rb', line 15

def to_s
  "#{@username}@#{@domain}"
end