Class: Blather::Stanza::Iq::Ping

Inherits:
Blather::Stanza::Iq show all
Defined in:
lib/blather/stanza/iq/ping.rb

Overview

# Ping Stanza

[XEP-0199: XMPP Ping](xmpp.org/extensions/xep-0199.html)

This is a base class for any Ping based Iq stanzas.

Constant Summary

Constants inherited from Blather::Stanza::Iq

VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Blather::Stanza::Iq

#error?, #get?, import, #reply!, #result?, #set?, #type=

Methods inherited from Blather::Stanza

#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply, #reply!, #to, #to=, #type, #type=

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Class Method Details

.new(type = :get, to = nil, id = nil) ⇒ Object

Overrides the parent method to ensure a ping node is created



19
20
21
22
23
# File 'lib/blather/stanza/iq/ping.rb', line 19

def self.new(type = :get, to = nil, id = nil)
  node = super
  node.ping
  node
end

Instance Method Details

#inherit(node) ⇒ Object

Overrides the parent method to ensure the current ping node is destroyed

See Also:

  • Blather::Stanza::Iq#inherit


28
29
30
31
# File 'lib/blather/stanza/iq/ping.rb', line 28

def inherit(node)
  ping.remove
  super
end

#pingBalather::XMPPNode

Ping node accessor If a ping node exists it will be returned. Otherwise a new node will be created and returned

Returns:

  • (Balather::XMPPNode)


38
39
40
41
42
43
44
45
46
# File 'lib/blather/stanza/iq/ping.rb', line 38

def ping
  p = find_first 'ns:ping', :ns => self.class.registered_ns

  unless p
    (self << (p = XMPPNode.new('ping', self.document)))
    p.namespace = self.class.registered_ns
  end
  p
end