<commit_before>module Ponder
  class Callback
    attr_reader :options

    def initialize(pattern = //, options = {}, proc = Proc.new {})
      unless pattern.is_a?(Regexp)
        raise TypeError, "Regexp for pattern expected, got #{match.class}"
      end
      unless proc.is_a?(Proc)
        raise TypeError, "Proc for proc expected, got #{proc.class}"
      end

      @pattern = pattern
      @proc = proc
      @options = options
    end

    def matching?(event)
      if [:channel, :query].include? event[:type]
        event[:message] =~ @pattern ? true : false
      elsif event[:type] == :topic
        event[:topic] =~ @pattern ? true : false
      else
        true
      end
    end

    def call(event)
      @proc.call(event) if matching?(event)
    end
  end
end<commit_msg>event shall be a Hash<commit_after>module Ponder
  class Callback
    attr_reader :options

    def initialize(pattern = //, options = {}, proc = Proc.new {})
      unless pattern.is_a?(Regexp)
        raise TypeError, "Regexp for pattern expected, got #{match.class}"
      end
      unless proc.is_a?(Proc)
        raise TypeError, "Proc for proc expected, got #{proc.class}"
      end

      @pattern = pattern
      @proc = proc
      @options = options
    end

    def matching?(event)
      if event.is_a? Hash
        if [:channel, :query].include? event[:type]
          event[:message] =~ @pattern ? true : false
        elsif event[:type] == :topic
          event[:topic] =~ @pattern ? true : false
        else
          true
        end
      else
        false
      end
    end

    def call(event)
      @proc.call(event) if matching?(event)
    end
  end
end
{'fraction_non_alphanumeric': 0.11144397843019772, 'fraction_numerical': 0.0, 'mean_word_length': 2.1273408239700373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2449100', 'n_tokens_mistral': 496, 'n_tokens_neox': 495, 'n_words': 147}