Class: XMPPSimple::Jid
- Inherits:
-
Object
- Object
- XMPPSimple::Jid
- Defined in:
- lib/xmpp_simple/jid.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username, host = nil) ⇒ Jid
constructor
A new instance of Jid.
- #to_s ⇒ Object
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
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
3 4 5 |
# File 'lib/xmpp_simple/jid.rb', line 3 def domain @domain end |
#username ⇒ Object (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_s ⇒ Object
15 16 17 |
# File 'lib/xmpp_simple/jid.rb', line 15 def to_s "#{@username}@#{@domain}" end |