Class Jabber::Delay::XDelay
In: lib/xmpp4r/delay/x/delay.rb
Parent: X

Implementation of JEP 0091 for <x xmlns=‘jabber:x:delay’ stamp=’…’ …/> applied on <message/> and <presence/> stanzas

One may also use XDelay#text for a descriptive reason for the delay.

Please note that you must require ‘xmpp4r/xdelay’ to use this class as it‘s not required by a basic XMPP implementation. <x/> elements with the specific namespace will then be converted to XDelay automatically.

Methods

from   from=   new   set_from   set_stamp   stamp   stamp=  

Public Class methods

Initialize a new XDelay element

insertnow:[Boolean] Set the stamp to [Time::now]

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 28
28:       def initialize(insertnow=true)
29:         super()
30:         add_namespace('jabber:x:delay')
31: 
32:         if insertnow
33:           set_stamp(Time.now)
34:         end
35:       end

Public Instance methods

Get the timestamp‘s origin

result:[JID]

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 75
75:       def from
76:         if attributes['from']
77:           JID::new(attributes['from'])
78:         else
79:           nil
80:         end
81:       end

Set the timestamp‘s origin

jid:[JID]

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 86
86:       def from=(jid)
87:         attributes['from'] = jid.nil? ? nil : jid.to_s
88:       end

Set the timestamp‘s origin (chaining-friendly)

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 92
92:       def set_from(jid)
93:         self.from = jid
94:         self
95:       end

Set the timestamp (chaining-friendly)

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 67
67:       def set_stamp(t)
68:         self.stamp = t
69:         self
70:       end

Get the timestamp

result:[Time] or nil

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 40
40:       def stamp
41:         if attributes['stamp']
42:           begin
43:             # Actually this should be Time.xmlschema,
44:             # but "unfortunately, the 'jabber:x:delay' namespace predates" JEP 0082
45:             Time.parse(attributes['stamp'])
46:           rescue ArgumentError
47:             nil
48:           end
49:         else
50:           nil
51:         end
52:       end

Set the timestamp

t:[Time] or nil

[Source]

    # File lib/xmpp4r/delay/x/delay.rb, line 57
57:       def stamp=(t)
58:         if t.nil?
59:           attributes['stamp'] = nil
60:         else
61:           attributes['stamp'] = t.strftime("%Y%m%dT%H:%M:%S")
62:         end
63:       end

[Validate]