<commit_before>module MaZMQ
  class SocketHandler
    def initialize(socket=nil)
      @connection = build_connection(socket)
      @connection.notify_readable = true
      @connection.notify_writable = true
    end

    def on_read(block)
      return false if block.arity != 1
      @connection.on_read(block)
    end

    def on_write(block)
      return false if block.arity != 1
      @connection.on_write(block)
    end

    private
    def build_connection(socket)
      fd = []
      socket.getsockopt(ZMQ::FD, fd)
      return nil if not ZMQ::Util.resultcode_ok? fd[0]
      EM.watch(fd[0], MaZMQ::ConnectionHandler, socket)<commit_msg>SocketHandler now has a reference for its socket object<commit_after>module MaZMQ
  class SocketHandler
    def initialize(socket)
      @socket = socket

      @connection = build_connection
      @connection.notify_readable = true
      @connection.notify_writable = true
    end

    def on_read(block)
      return false if block.arity != 1
      @connection.on_read(block)
    end

    def on_write(block)
      return false if block.arity != 1
      @connection.on_write(block)
    end

    def socket_type
      @socket.socket_type
    end

    private
    def build_connection
      fd = []
      @socket.getsockopt(ZMQ::FD, fd)
      return nil if not ZMQ::Util.resultcode_ok? fd[0]
      EM.watch(fd[0], MaZMQ::ConnectionHandler, @socket)
{'fraction_non_alphanumeric': 0.08686288585786073, 'fraction_numerical': 0.00574300071787509, 'mean_word_length': 2.7983651226158037, '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': '5910366', 'n_tokens_mistral': 447, 'n_tokens_neox': 423, 'n_words': 105}