Class: Jabber::Observable::Contact
- Inherits:
-
Object
- Object
- Jabber::Observable::Contact
- Defined in:
- lib/xmpp4r/observable/contact.rb
Overview
Jabber::Observable::Contact - Convenience subclass to deal with Contacts
Instance Method Summary collapse
-
#ask_for_authorization! ⇒ Object
Send a request asking for authorization.
-
#initialize(jid, observable) ⇒ Contact
constructor
Creates a new Jabber::Observable::Contact.
-
#inspect ⇒ Object
:nodoc:.
-
#jid ⇒ Object
Returns the stripped version of the JID.
-
#subscribed? ⇒ Boolean
Are e subscribed?.
-
#subscription ⇒ Object
Get the subscription from the roster_item.
-
#unsubscribe! ⇒ Object
Sends a request asking for unsubscription.
Constructor Details
#initialize(jid, observable) ⇒ Contact
Creates a new Jabber::Observable::Contact
- jid
-
jid to be used
- observable
-
observable to be used
16 17 18 19 |
# File 'lib/xmpp4r/observable/contact.rb', line 16 def initialize(jid, observable) @jid = jid.respond_to?(:resource) ? jid : JID.new(jid) @observable = observable end |
Instance Method Details
#ask_for_authorization! ⇒ Object
Send a request asking for authorization
41 42 43 |
# File 'lib/xmpp4r/observable/contact.rb', line 41 def request!(:subscribe) end |
#inspect ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/xmpp4r/observable/contact.rb', line 24 def inspect #:nodoc: sprintf("#<%s:0x%x @jid=%s>", self.class.name, __id__, @jid.to_s) end |
#jid ⇒ Object
Returns the stripped version of the JID
22 |
# File 'lib/xmpp4r/observable/contact.rb', line 22 def jid; @jid.strip; end |
#subscribed? ⇒ Boolean
Are e subscribed?
29 30 31 |
# File 'lib/xmpp4r/observable/contact.rb', line 29 def subscribed? [:to, :both].include?(subscription) end |
#subscription ⇒ Object
Get the subscription from the roster_item
34 35 36 37 38 |
# File 'lib/xmpp4r/observable/contact.rb', line 34 def subscription items = @observable.roster.items return false unless items.include?(jid) items[jid].subscription end |
#unsubscribe! ⇒ Object
Sends a request asking for unsubscription
46 47 48 |
# File 'lib/xmpp4r/observable/contact.rb', line 46 def unsubscribe! request!(:unsubscribe) end |