Class: AgentXmpp::Xmpp::IqVersion

Inherits:
IqQuery show all
Defined in:
lib/agent_xmpp/xmpp/iq_version.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

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(iname = nil, version = nil, os = nil) ⇒ IqVersion

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



45
46
47
48
49
50
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 45

def initialize(iname=nil, version=nil, os=nil)
  super()
  self.iname = iname if iname
  self.version = version if version
  self.os = os if os
end

Class Method Details

.get(pipe, contact_jid) ⇒ Object

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



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 18

def get(pipe, contact_jid)
  iq = Xmpp::Iq.new(:get, contact_jid)
  iq.query = new
  Send(iq) do |r|
    if (r.type == :result) && r.query.kind_of?(Xmpp::IqVersion)
      pipe.broadcast_to_delegates(:on_version_result, pipe, r)
    elsif r.type.eql?(:error)
      pipe.broadcast_to_delegates(:on_version_error, pipe, r)
    end
  end
end

.result(pipe, request) ⇒ Object

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



31
32
33
34
35
36
37
38
39
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 31

def result(pipe, request)
  iq = Xmpp::Iq.new(:result, request.from.to_s)
  iq.id = request.id unless request.id.nil?
  iq.query = new
  iq.query.iname = AgentXmpp::AGENT_XMPP_NAME
  iq.query.version = AgentXmpp::VERSION
  iq.query.os = AgentXmpp::OS_VERSION
  Send(iq)
end

Instance Method Details

#inameObject

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



53
54
55
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 53

def iname
  first_element_text('name')
end

#iname=(text) ⇒ Object

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



58
59
60
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 58

def iname=(text)
  replace_element_text('name', text.nil? ? '' : text)
end

#osObject

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



73
74
75
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 73

def os
  first_element_text('os')
end

#os=(text) ⇒ Object

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



78
79
80
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 78

def os=(text)
  replace_element_text('os', text.nil? ? '' : text)
end

#versionObject

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



63
64
65
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 63

def version
  first_element_text('version')
end

#version=(text) ⇒ Object

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



68
69
70
# File 'lib/agent_xmpp/xmpp/iq_version.rb', line 68

def version=(text)
  replace_element_text('version', text.nil? ? '' : text)
end