Sha256: 2d097362cb1f667beb41fc9798ef5612662286e90504e13b9725345b7fe96ca4

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

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

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

1 entries across 1 versions & 1 rubygems

Version Path
xmpp4r-0.5.6 lib/xmpp4r/last/iq/last.rb