Class: Jabber::Contact
- Inherits:
-
Object
- Object
- Jabber::Contact
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/external/xmpp4r-simple.rb
Overview
:nodoc:
Instance Method Summary collapse
- #ask_for_authorization! ⇒ Object
-
#initialize(client, jid) ⇒ Contact
constructor
A new instance of Contact.
- #inspect ⇒ Object
- #jid(bare = true) ⇒ Object
- #subscribed? ⇒ Boolean
- #subscription ⇒ Object
- #unsubscribe! ⇒ Object
Constructor Details
#initialize(client, jid) ⇒ Contact
Returns a new instance of Contact.
35 36 37 38 |
# File 'lib/external/xmpp4r-simple.rb', line 35 def initialize(client, jid) @jid = jid.respond_to?(:resource) ? jid : JID.new(jid) @client = client end |
Instance Method Details
#ask_for_authorization! ⇒ Object
52 53 54 55 56 |
# File 'lib/external/xmpp4r-simple.rb', line 52 def subscription_request = Presence.new.set_type(:subscribe) subscription_request.to = jid client.send!(subscription_request) end |
#inspect ⇒ Object
40 41 42 |
# File 'lib/external/xmpp4r-simple.rb', line 40 def inspect "Jabber::Contact #{jid.to_s}" end |
#jid(bare = true) ⇒ Object
65 66 67 |
# File 'lib/external/xmpp4r-simple.rb', line 65 def jid(=true) ? @jid.strip : @jid end |
#subscribed? ⇒ Boolean
44 45 46 |
# File 'lib/external/xmpp4r-simple.rb', line 44 def subscribed? [:to, :both].include?(subscription) end |
#subscription ⇒ Object
48 49 50 |
# File 'lib/external/xmpp4r-simple.rb', line 48 def subscription roster_item && roster_item.subscription end |
#unsubscribe! ⇒ Object
58 59 60 61 62 63 |
# File 'lib/external/xmpp4r-simple.rb', line 58 def unsubscribe! unsubscription_request = Presence.new.set_type(:unsubscribe) unsubscription_request.to = jid client.send!(unsubscription_request) client.send!(unsubscription_request.set_type(:unsubscribed)) end |