Sha256: a6b923e76444bed622b0f95103eb0080882c62e9ec7928b2c52e4573f80e53bd

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module RocketChat
  #
  # Rocket.Chat Message
  #
  class Message
    # Raw user data
    attr_reader :data

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

    # Message ID
    def id
      data['_id']
    end

    # Timestamp
    def timestamp
      Time.parse data['ts']
    end

    # Updated at
    def updated_at
      Time.parse data['_updatedAt']
    end

    # Room ID
    def room_id
      data['rid']
    end

    # User
    def user
      User.new data['u']
    end

    # Message
    def message
      data['msg']
    end

    # Alias
    def alias
      data['alias']
    end

    # Parse URLs
    def parse_urls
      data['parseUrls']
    end

    # Groupable
    def groupable
      data['groupable']
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

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