Sha256: 2071172720cb9a4e64d9e2cb8b300968118b9ee029ccd839da05d59aefecbd1f

Contents?: true

Size: 576 Bytes

Versions: 3

Compression:

Stored size: 576 Bytes

Contents

module Slappy
  class Event
    extend Forwardable

    attr_accessor :matches

    def_delegators :@data, :method_missing, :respond_to_missing?

    def initialize(data)
      @data = Hashie::Mash.new data
    end

    def text
      @data['text'].to_s
    end

    def channel
      SlackAPI::Channel.find(id: @data['channel']) ||
        SlackAPI::Group.find(id: @data['channel']) ||
        SlackAPI::Direct.find(id: @data['channel'])
    end

    def user
      SlackAPI::User.find(id: @data['user'])
    end

    def ts
      Time.at(@data['ts'].to_f)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slappy-0.5.2 lib/slappy/event.rb
slappy-0.5.1 lib/slappy/event.rb
slappy-0.5.0 lib/slappy/event.rb