Class Jabber::XDelay
In: lib/xmpp4r/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/x/delay.rb, line 27
27:     def initialize(insertnow=true)
28:       super()
29:       add_namespace('jabber:x:delay')
30: 
31:       if insertnow
32:         set_stamp(Time.now)
33:       end
34:     end

Public Instance methods

Get the timestamp’s origin

result:[JID]

[Source]

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

Set the timestamp’s origin

jid:[JID]

[Source]

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

Set the timestamp’s origin (chaining-friendly)

[Source]

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

Set the timestamp (chaining-friendly)

[Source]

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

Get the timestamp

result:[Time] or nil

[Source]

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

Set the timestamp

t:[Time] or nil

[Source]

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

[Validate]