Class: XMPPBot::Presence
- Inherits:
-
Object
- Object
- XMPPBot::Presence
- Defined in:
- lib/xmppbot/presence.rb
Instance Attribute Summary collapse
-
#stanza ⇒ Object
readonly
Returns the value of attribute stanza.
Instance Method Summary collapse
- #from ⇒ Object
-
#initialize(stanza = nil) ⇒ Presence
constructor
A new instance of Presence.
- #show ⇒ Object
- #to ⇒ Object
- #to=(to) ⇒ Object
-
#to_s ⇒ Object
returns the show (away, dnd, chat,xa).
- #type ⇒ Object
- #type=(type) ⇒ Object
Constructor Details
#initialize(stanza = nil) ⇒ Presence
Returns a new instance of Presence.
11 12 13 14 15 16 17 18 |
# File 'lib/xmppbot/presence.rb', line 11 def initialize(stanza=nil) if stanza @stanza=stanza else @stanza = StropheRuby::Stanza.new @stanza.name = "presence" end end |
Instance Attribute Details
#stanza ⇒ Object (readonly)
Returns the value of attribute stanza.
9 10 11 |
# File 'lib/xmppbot/presence.rb', line 9 def stanza @stanza end |
Instance Method Details
#from ⇒ Object
20 21 22 |
# File 'lib/xmppbot/presence.rb', line 20 def from self.stanza.attribute("from") end |
#show ⇒ Object
40 41 42 43 |
# File 'lib/xmppbot/presence.rb', line 40 def show s=self.stanza.child_by_name("show") s ? s.text : nil end |
#to ⇒ Object
24 25 26 |
# File 'lib/xmppbot/presence.rb', line 24 def to self.stanza.attribute("to") end |
#to=(to) ⇒ Object
28 29 30 |
# File 'lib/xmppbot/presence.rb', line 28 def to=(to) self.stanza.set_attribute("to",to) end |
#to_s ⇒ Object
returns the show (away, dnd, chat,xa). if there is none, returns the type which can be : unavailable subscribe,subscribed,unsubscribe,unsubscribed,probe or error.
47 48 49 50 |
# File 'lib/xmppbot/presence.rb', line 47 def to_s res = self.show res ? res : self.type ? self.type : "available" end |
#type ⇒ Object
32 33 34 |
# File 'lib/xmppbot/presence.rb', line 32 def type self.stanza.type end |
#type=(type) ⇒ Object
36 37 38 |
# File 'lib/xmppbot/presence.rb', line 36 def type=(type) self.stanza.type=type end |