Class: Jabber::Contact

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped
Defined in:
lib/xmpp4r-simple.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(client, jid) ⇒ Contact

Returns a new instance of Contact.



63
64
65
66
# File 'lib/xmpp4r-simple.rb', line 63

def initialize(client, jid)
  @jid = jid.respond_to?(:resource) ? jid : JID.new(jid)
  @client = client
end

Instance Method Details

#ask_for_authorization!Object



80
81
82
83
84
# File 'lib/xmpp4r-simple.rb', line 80

def ask_for_authorization!
  subscription_request = Presence.new.set_type(:subscribe)
  subscription_request.to = jid
  client.send!(subscription_request)
end

#inspectObject



68
69
70
# File 'lib/xmpp4r-simple.rb', line 68

def inspect
  "Jabber::Contact #{jid.to_s}"
end

#jid(bare = true) ⇒ Object



93
94
95
# File 'lib/xmpp4r-simple.rb', line 93

def jid(bare=true)
  bare ? @jid.strip : @jid
end

#subscribed?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/xmpp4r-simple.rb', line 72

def subscribed?
  [:to, :both].include?(subscription)
end

#subscriptionObject



76
77
78
# File 'lib/xmpp4r-simple.rb', line 76

def subscription
  roster_item && roster_item.subscription
end

#unsubscribe!Object



86
87
88
89
90
91
# File 'lib/xmpp4r-simple.rb', line 86

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