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

- (Contact) initialize(client, jid)

Returns a new instance of Contact



32
33
34
35
# File 'lib/xmpp4r-simple.rb', line 32

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

Instance Method Details

- (Object) ask_for_authorization!



49
50
51
52
53
# File 'lib/xmpp4r-simple.rb', line 49

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

- (Object) inspect



37
38
39
# File 'lib/xmpp4r-simple.rb', line 37

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

- (Object) jid(bare = true)



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

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

- (Boolean) subscribed?

Returns:

  • (Boolean)


41
42
43
# File 'lib/xmpp4r-simple.rb', line 41

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

- (Object) subscription



45
46
47
# File 'lib/xmpp4r-simple.rb', line 45

def subscription
  roster_item && roster_item.subscription
end

- (Object) unsubscribe!



55
56
57
58
59
60
# File 'lib/xmpp4r-simple.rb', line 55

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