Class: Jabber::Version::IqQueryVersion

Inherits:
IqQuery show all
Defined in:
lib/xmpp4r/version/iq/version.rb

Overview

Class for handling queries for 'Software Version' (JEP 0092)

Notice that according to JEP 0092 only the <os/> element can be omitted, <name/> (iname) and <version/> must be present

Instance Method Summary collapse

Methods inherited from XMPPElement

class_for_name_xmlns, #clone, force_xmlns, force_xmlns?, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=

Methods inherited from REXML::Element

#==, #delete_elements, #each_elements, #first_element, #first_element_content, #first_element_text, #import, import, #replace_element_content, #replace_element_text, #typed_add

Constructor Details

#initialize(iname = nil, version = nil, os = nil) ⇒ IqQueryVersion

Create a new <query xmlns='jabber:iq:version'/> element



20
21
22
23
24
25
# File 'lib/xmpp4r/version/iq/version.rb', line 20

def initialize(iname=nil, version=nil, os=nil)
  super()
  set_iname(iname) if iname
  set_version(version) if version
  set_os(os) if os
end

Instance Method Details

#inameObject

Get the name of the software

This has been renamed to 'iname' here to keep REXML::Element#name accessible



32
33
34
# File 'lib/xmpp4r/version/iq/version.rb', line 32

def iname
  first_element_text('name')
end

#iname=(text) ⇒ Object

Set the name of the software

The element won't be deleted if text is nil as it must occur in a version query, but its text will be empty.



42
43
44
# File 'lib/xmpp4r/version/iq/version.rb', line 42

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

#osObject

Get the operating system or nil (os is not mandatory for Version Query)



81
82
83
# File 'lib/xmpp4r/version/iq/version.rb', line 81

def os
  first_element_text('os')
end

#os=(text) ⇒ Object

Set the os of the software

text
String

or nil



88
89
90
91
92
93
94
# File 'lib/xmpp4r/version/iq/version.rb', line 88

def os=(text)
  if text
    replace_element_text('os', text)
  else
    delete_elements('os')
  end
end

#set_iname(text) ⇒ Object

Set the name of the software (chaining-friendly)

result
String

or nil



49
50
51
52
# File 'lib/xmpp4r/version/iq/version.rb', line 49

def set_iname(text)
  self.iname = text
  self
end

#set_os(text) ⇒ Object

Set the os of the software (chaining-friendly)

text
String

or nil



99
100
101
102
# File 'lib/xmpp4r/version/iq/version.rb', line 99

def set_os(text)
  self.os = text
  self
end

#set_version(text) ⇒ Object

Set the version of the software (chaining-friendly)

text
String


73
74
75
76
# File 'lib/xmpp4r/version/iq/version.rb', line 73

def set_version(text)
  self.version = text
  self
end

#versionObject

Get the version of the software

result
String

or nil



57
58
59
# File 'lib/xmpp4r/version/iq/version.rb', line 57

def version
  first_element_text('version')
end

#version=(text) ⇒ Object

Set the version of the software

The element won't be deleted if text is nil as it must occur in a version query



66
67
68
# File 'lib/xmpp4r/version/iq/version.rb', line 66

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