Sha256: b2f89b35450f340c54b88d1c8d49a2b88f558ddce6f6c3f25f48d78e3bc6c88f

Contents?: true

Size: 774 Bytes

Versions: 4

Compression:

Stored size: 774 Bytes

Contents

module RocketChat
  #
  # Rocket.Chat PresenceStatus
  #
  class PresenceStatus
    # Raw presence status data
    attr_reader :data

    #
    # @param [Hash] data Raw presence status data
    #
    def initialize(data)
      @data = Util.stringify_hash_keys data
    end

    # Presence
    def presence
      data['presence']
    end

    # Connection status
    def connection_status
      data['connectionStatus']
    end

    # Last login
    def last_login
      Time.parse data['lastLogin']
    rescue ArgumentError, TypeError
      nil
    end

    def inspect
      format(
        '#<%<class_name>s:0x%<object_id>p @presence="%<presence>s">',
        class_name: self.class.name,
        object_id: object_id,
        presence: presence
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rocketchat-0.1.18 lib/rocket_chat/presence_status.rb
rocketchat-0.1.17 lib/rocket_chat/presence_status.rb
rocketchat-0.1.16 lib/rocket_chat/presence_status.rb
rocketchat-0.1.15 lib/rocket_chat/presence_status.rb