Class: Jabber::Roster::RosterItem::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/jabber4r/roster.rb

Overview

The Resource class embodies a Resource endpoint in Jabber. The resource endpoint it what maintains a status (not an account).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, name, show, status) ⇒ Resource

Constructs a new Resource instance

item

[Jabber::Roster::RosterItem] The roster item this resource belongs to

name

[String] The resource name

show

[String] How the resource should be shown

status

[String] The status message of the resource



96
97
98
99
100
101
# File 'lib/jabber4r/roster.rb', line 96

def initialize(item, name, show, status)
  @item = item
  @name = name
  @show = show
  @status = status
end

Instance Attribute Details

#nameObject (readonly)

The name of the resource



80
81
82
# File 'lib/jabber4r/roster.rb', line 80

def name
  @name
end

#showObject (readonly)

How the resource should be shown



83
84
85
# File 'lib/jabber4r/roster.rb', line 83

def show
  @show
end

#statusObject (readonly)

The status message of the resource



86
87
88
# File 'lib/jabber4r/roster.rb', line 86

def status
  @status
end

Instance Method Details

#to_sObject

Dumps the Resource as a string

return

[String] The resource encoded as a string.



120
121
122
# File 'lib/jabber4r/roster.rb', line 120

def to_s
  "RESOURCE:#{@name} SHOW:#{@show} STATUS:#{@status}"
end

#update(show, status) ⇒ Object

Updates the state of a resource and notifies listeners.

show

[String] How the resource should be shown

status

[String] The status message of the resource



109
110
111
112
113
# File 'lib/jabber4r/roster.rb', line 109

def update(show, status)
  @show = show
  @status = status
  @item.roster.notify_listeners(RESOURCE_UPDATED, self)
end