Class: Jabber::Contact
- Inherits:
-
Object
- Object
- Jabber::Contact
- Defined in:
- lib/xmpp4r-observable.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.
43 44 45 46 |
# File 'lib/xmpp4r-observable.rb', line 43 def initialize(client, jid) @jid = jid.respond_to?(:resource) ? jid : JID.new(jid) @client = client end |
Instance Method Details
#ask_for_authorization! ⇒ Object
60 61 62 63 64 |
# File 'lib/xmpp4r-observable.rb', line 60 def subscription_request = Jabber::Presence.new.set_type(:subscribe) subscription_request.to = jid client.send!(subscription_request) end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/xmpp4r-observable.rb', line 48 def inspect sprintf("#<%s:0x%x @jid=%s>", self.class.name, __id__, @jid.to_s) end |
#jid(bare = true) ⇒ Object
73 74 75 |
# File 'lib/xmpp4r-observable.rb', line 73 def jid(=true) ? @jid.strip : @jid end |
#subscribed? ⇒ Boolean
52 53 54 |
# File 'lib/xmpp4r-observable.rb', line 52 def subscribed? [:to, :both].include?(subscription) end |
#subscription ⇒ Object
56 57 58 |
# File 'lib/xmpp4r-observable.rb', line 56 def subscription roster_item && roster_item.subscription end |
#unsubscribe! ⇒ Object
66 67 68 69 70 71 |
# File 'lib/xmpp4r-observable.rb', line 66 def unsubscribe! unsubscription_request = Jabber::Presence.new.set_type(:unsubscribe) unsubscription_request.to = jid client.send!(unsubscription_request) client.send!(unsubscription_request.set_type(:unsubscribed)) end |