Sha256: 6479882909acf105cc6dc4ee588e08569766cbc0c25feb16cf5e9f35159c91bb

Contents?: true

Size: 395 Bytes

Versions: 2

Compression:

Stored size: 395 Bytes

Contents

module Slappy
  class Listener
    def initialize(pattern, callback)
      pattern = /#{pattern}/ if pattern.is_a? String
      @regexp = pattern
      @callback = callback
    end

    def call(event)
      return unless Time.at(event.ts.to_f) > Slappy.start_time
      return unless event.text.match @regexp
      @callback.call(event)
    end

    def pattern
      @regexp
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slappy-0.3.0 lib/slappy/listener.rb
slappy-0.2.1 lib/slappy/listener.rb