Class: Jabber::Delay::XDelay

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

new(insertnow=true)

Initialize a new XDelay element

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

[Source]

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

### Public Instance methods

from()

Get the timestamp‘s origin

result: | [JID]

[Source]

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

from=(jid)

Set the timestamp‘s origin

jid: | [JID]

[Source]

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

set_from(jid)

Set the timestamp‘s origin (chaining-friendly)

[Source]

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

set_stamp(t)

Set the timestamp (chaining-friendly)

[Source]

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

stamp()

Get the timestamp

result: | [Time] or nil

[Source]

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

stamp=(t)

Set the timestamp

t: | [Time] or nil

[Source]

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

[Validate]