Class: AgentXmpp::Xmpp::Stanza

Inherits:
Element show all
Defined in:
lib/agent_xmpp/xmpp/stanza.rb

Overview


Direct Known Subclasses

Iq, Message, Presence

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#<<, class_for_name_xmlns, #clone, import, #initialize, 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

This class inherits a constructor from AgentXmpp::Xmpp::Element

Class Method Details

.answer(stanza, import = true) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



34
35
36
37
38
39
40
41
42
43
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 34

def Stanza.answer(stanza, import=true)
  x = stanza.class.new
  if import
    x.import(stanza)
  end
  x.from = stanza.to
  x.to = stanza.from
  x.id = stanza.id
  x
end

Instance Method Details

#answer(import = true) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



51
52
53
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 51

def answer(import=true)
  Stanza.answer(self, import)
end

#errorObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



46
47
48
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 46

def error
  first_element('error')
end

#fromObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



70
71
72
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 70

def from
  (a = attribute('from')).nil? ? a : Jid.new(a.value)
end

#from=(v) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



75
76
77
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 75

def from=(v)
  add_attribute('from', v ? v.to_s : nil)
end

#idObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



80
81
82
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 80

def id
  (a = attribute('id')).nil? ? a : a.value
end

#id=(v) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



85
86
87
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 85

def id=(v)
  add_attribute('id', v.to_s)
end

#normalizeObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



56
57
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 56

def normalize
end

#toObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



60
61
62
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 60

def to
  (a = attribute('to')).nil? ? a : Jid.new(a.value)
end

#to=(v) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



65
66
67
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 65

def to=(v)
  add_attribute('to', v ? v.to_s : nil)
end

#typeObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



90
91
92
93
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 90

def type
  stanza_type = attributes['type']
  stanza_type.nil? ? nil : stanza_type.to_sym
end

#type=(t) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



96
97
98
# File 'lib/agent_xmpp/xmpp/stanza.rb', line 96

def type=(t)
  attributes['type'] = t.to_s
end