Class: AgentXmpp::Xmpp::Message

Inherits:
Stanza show all
Includes:
XParent
Defined in:
lib/agent_xmpp/xmpp/message.rb

Overview


Class Method Summary collapse

Instance Method Summary collapse

Methods included from XParent

#x

Methods inherited from Stanza

answer, #answer, #error, #from, #from=, #id, #id=, #normalize, #to, #to=, #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(to = nil, body = nil) ⇒ Message

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



32
33
34
35
36
# File 'lib/agent_xmpp/xmpp/message.rb', line 32

def initialize(to = nil, body = nil)
  super()
  self.to = to if to
  add_element(REXML::Element.new("body").add_text(body)) if body
end

Class Method Details

.chat(to, body) ⇒ Object

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



19
20
21
22
23
# File 'lib/agent_xmpp/xmpp/message.rb', line 19

def chat(to, body)
  message = Xmpp::Message.new(to, body)
  message.type = :chat
  Send(message)  
end

Instance Method Details

#bodyObject

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



45
46
47
# File 'lib/agent_xmpp/xmpp/message.rb', line 45

def body
  first_element_text('body')
end

#body=(b) ⇒ Object

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



50
51
52
# File 'lib/agent_xmpp/xmpp/message.rb', line 50

def body=(b)
  replace_element_text('body', b)
end

#subjectObject

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



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

def subject
  first_element_text('subject')
end

#subject=(s) ⇒ Object

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



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

def subject=(s)
  replace_element_text('subject', s)
end

#threadObject

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



71
72
73
# File 'lib/agent_xmpp/xmpp/message.rb', line 71

def thread
  first_element_text('thread')
end

#thread=(s) ⇒ Object

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



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

def thread=(s)
  delete_elements('thread')
  replace_element_text('thread', s) if s
end

#typeObject

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



39
40
41
42
# File 'lib/agent_xmpp/xmpp/message.rb', line 39

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