Sha256: b7d4458c60edf7270d117642282019297405d0893e5c09914ba58737fb4496c9

Contents?: true

Size: 1.65 KB

Versions: 15

Compression:

Stored size: 1.65 KB

Contents

# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://home.gna.org/xmpp4r/

require 'xmpp4r/query'

module Jabber
  module LastActivity
    NS_LAST_ACTIVITY = 'jabber:iq:last'

    ##
    # Class for handling Last Activity queries
    # (XEP-0012)
    class IqQueryLastActivity < IqQuery
      name_xmlns 'query', NS_LAST_ACTIVITY

      ##
      # Get the number of seconds since last activity.
      #
      # With a bare jid, this will return the number of seconds since the
      # client was last seen (offline user query).
      #
      # With a full jid, this will return the number of seconds that the
      # client has been idle (online user query).
      #
      # With a server, this will return the server or component's uptime in
      # seconds (server / component query).
      def seconds
        attributes['seconds'] ? attributes['seconds'].to_i : nil
      end

      ##
      # Set the number of seconds since last activity
      def seconds=(val)
        attributes['seconds'] = val.to_s
      end

      ##
      # Set the number of seconds since last activity
      # (chaining-friendly)
      def set_second(val)
        self.seconds = val
        self
      end

      ##
      # For an offline user query, get the last status.
      def status
        self.text
      end

      ##
      # For an offline user query, set the last status.
      def status=(val)
        self.text = val
      end

      ##
      # For an offline user query, set the last status.
      # (chaining-friendly)
      def set_status(val)
        self.status = val
        self
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
brontes3d-xmpp4r-0.4 lib/xmpp4r/last/iq/last.rb
ln-xmpp4r-0.5 lib/xmpp4r/last/iq/last.rb
mojodna-xmpp4r-0.4.0.2 lib/xmpp4r/last/iq/last.rb
mojodna-xmpp4r-0.4.0.3 lib/xmpp4r/last/iq/last.rb
seanohalpin-xmpp4r-0.4.1 lib/xmpp4r/last/iq/last.rb
xmpp4r-0.5.5 lib/xmpp4r/last/iq/last.rb
gmcmillan-xmpp4r-0.6.2 lib/xmpp4r/last/iq/last.rb
gmcmillan-xmpp4r-0.6.1 lib/xmpp4r/last/iq/last.rb
gmcmillan-xmpp4r-0.6 lib/xmpp4r/last/iq/last.rb
gmcmillan-xmpp4r-0.5 lib/xmpp4r/last/iq/last.rb
mad-p-xmpp4r-0.6.3 lib/xmpp4r/last/iq/last.rb
mad-p-xmpp4r-0.6.2 lib/xmpp4r/last/iq/last.rb
mad-p-xmpp4r-0.6.1 lib/xmpp4r/last/iq/last.rb
mad-p-xmpp4r-0.6.0 lib/xmpp4r/last/iq/last.rb
xmpp4r-0.5 lib/xmpp4r/last/iq/last.rb