Class: AgentXmpp::Xmpp::Presence
- Includes:
- XParent, Comparable
- Defined in:
- lib/agent_xmpp/xmpp/presence.rb
Overview
Constant Summary collapse
- PRESENCE_STATUS =
.….….….….….….….….….….….….….….….….….….….….….….….….……
{ :chat => 4, nil => 3, :dnd => 2, :away => 1, :xa => 0, :unavailable => -1, :error => -2 }
Class Method Summary collapse
-
.accept(contact_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.decline(contact_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.subscribe(contact_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Instance Method Summary collapse
-
#<=>(o) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#cmp_interest(o) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#initialize(show = nil, status = nil, priority = nil) ⇒ Presence
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#priority ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#priority=(val) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#show ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#show=(val) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#status ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#status=(val) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
Methods included from XParent
Methods inherited from Stanza
answer, #answer, #error, #from, #from=, #id, #id=, #normalize, #to, #to=, #type, #type=
Methods inherited from Element
#<<, class_for_name_xmlns, #clone, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=, xmpp_attribute, xmpp_child
Methods inherited from REXML::Element
#delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text, #typed_add
Constructor Details
#initialize(show = nil, status = nil, priority = nil) ⇒ Presence
.….….….….….….….….….….….….….….….….….….….….….….….….……
49 50 51 52 53 54 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 49 def initialize(show=nil, status=nil, priority=nil) super() self.show = show if show self.status = status if status self.priority = priority if priority end |
Class Method Details
.accept(contact_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
22 23 24 25 26 27 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 22 def accept(contact_jid) pres = Xmpp::Presence.new pres.type = :subscribed pres.to = contact_jid Send(pres) end |
Instance Method Details
#<=>(o) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
97 98 99 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 97 def <=>(o) priority.to_i == o.priority.to_i ? cmp_interest(o) : priority.to_i <=> o.priority.to_i end |
#cmp_interest(o) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
110 111 112 113 114 115 116 117 118 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 110 def cmp_interest(o) if type.nil? o.type.nil? ? PRESENCE_STATUS[show] <=> PRESENCE_STATUS[o.show] : -1 elsif o.type.nil? return 1 else return 0 end end |
#priority ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
87 88 89 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 87 def priority (e = first_element_text('priority')).nil? ? nil : e.to_i end |
#priority=(val) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
92 93 94 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 92 def priority=(val) val.nil? ? delete_element('priority') : replace_element_text('priority', val) end |
#show ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
57 58 59 60 61 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 57 def show e = first_element('show') text = e ? e.text : nil text.to_sym end |
#show=(val) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 64 def show=(val) xe = first_element('show') if xe.nil? xe = add_element('show') end if text.nil? delete_element(xe) else xe.text = text end end |
#status ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
77 78 79 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 77 def status first_element_text('status') end |
#status=(val) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
82 83 84 |
# File 'lib/agent_xmpp/xmpp/presence.rb', line 82 def status=(val) val.nil? ? delete_element('status') : replace_element_text('status', val) end |