<commit_before>module CZTop::FFIDelegate
  # @return [CZMQ::FFI::*]
  attr_accessor :ffi_delegate

  # @return [FFI::Pointer] FFI delegate's pointer
  def to_ptr
    @ffi_delegate.to_ptr
  end

  # Attaches an FFI delegate to the current (probably new) {CZTop} object.
  # @param ffi_delegate an instance of the corresponding class in the {CZMQ::FFI} namespace
  # @raise [CZTop::InitializationError] if delegate is #null?
  def attach_ffi_delegate(ffi_delegate)
    raise CZTop::InitializationError if ffi_delegate.null?
    self.ffi_delegate = ffi_delegate
  end

  module ClassMethods
    # Delegate specified instance methods to the registered FFI delegates.
    # @param methods [Array<Symbol>] methods to delegate
    def ffi_delegate(*methods)
      def_delegators(:@ffi_delegate, *methods)
    end

    def from_ffi_delegate(ffi_delegate)
      obj = new
      obj.attach_ffi_delegate(ffi_delegate)
      return obj
    end
  end

  def self.included(m)
    m.class_eval do
      extend Forwardable
      extend ClassMethods
    end
  end
end<commit_msg>use ::allocate instead of ::new<commit_after>module CZTop::FFIDelegate
  # @return [CZMQ::FFI::*]
  attr_accessor :ffi_delegate

  # @return [FFI::Pointer] FFI delegate's pointer
  def to_ptr
    @ffi_delegate.to_ptr
  end

  # Attaches an FFI delegate to the current (probably new) {CZTop} object.
  # @param ffi_delegate an instance of the corresponding class in the {CZMQ::FFI} namespace
  # @raise [CZTop::InitializationError] if delegate is #null?
  def attach_ffi_delegate(ffi_delegate)
    raise CZTop::InitializationError if ffi_delegate.null?
    self.ffi_delegate = ffi_delegate
  end

  module ClassMethods
    # Delegate specified instance methods to the registered FFI delegates.
    # @param methods [Array<Symbol>] methods to delegate
    def ffi_delegate(*methods)
      def_delegators(:@ffi_delegate, *methods)
    end

    def from_ffi_delegate(ffi_delegate)
      obj = allocate
      obj.attach_ffi_delegate(ffi_delegate)
      return obj
    end
  end

  def self.included(m)
    m.class_eval do
      extend Forwardable
      extend ClassMethods
    end
  end
end
{'fraction_non_alphanumeric': 0.07545412203074056, 'fraction_numerical': 0.0, 'mean_word_length': 3.7417218543046356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1748423', 'n_tokens_mistral': 718, 'n_tokens_neox': 690, 'n_words': 193}