<commit_before>module TreeNode
  class Node
    def initialize(object, parent_id, options)
      @object = object
      @parent_id = parent_id
      @options = options
    end

    def self.set_attribute(attribute, value = nil, &block)
      atvar = "@#{attribute}".to_sym

      define_method(attribute) do
        result = instance_variable_get(atvar)

        if result.nil?
          if block_given?
            args = [@object, @options, @parent_id].take(block.arity.abs)
            result = instance_exec(*args, &block)
          else
            result = value
          end
          instance_variable_set(atvar, result)
        end

        result
      end

      equals_method(attribute)
    end

    def self.set_attributes(*attributes, &block)
      attributes.each do |attribute|
        define_method(attribute) do
          result = instance_variable_get("@#{attribute}".to_sym)

          if result.nil?
            results = instance_eval(&block)
            attributes.each_with_index do |local, index|
              instance_variable_set("@#{local}".to_sym, results[index])
              result = results[index] if local == attribute
            end
          end

          result
        end

        equals_method(attribute)
      end
    end

    def self.equals_method(attribute)
      define_method("#{attribute}=".to_sym) do |result|
        instance_variable_set("@#{attribute}".to_sym, result)
      end
    end

    def title
      @object.name
    end

    def tooltip
      nil
    end

    def icon
      nil
    end

    def klass
      nil
    end<commit_msg>Provide a default `nil` image for each node if it has an icon<commit_after>module TreeNode
  class Node
    def initialize(object, parent_id, options)
      @object = object
      @parent_id = parent_id
      @options = options
    end

    def self.set_attribute(attribute, value = nil, &block)
      atvar = "@#{attribute}".to_sym

      define_method(attribute) do
        result = instance_variable_get(atvar)

        if result.nil?
          if block_given?
            args = [@object, @options, @parent_id].take(block.arity.abs)
            result = instance_exec(*args, &block)
          else
            result = value
          end
          instance_variable_set(atvar, result)
        end

        result
      end

      equals_method(attribute)
    end

    def self.set_attributes(*attributes, &block)
      attributes.each do |attribute|
        define_method(attribute) do
          result = instance_variable_get("@#{attribute}".to_sym)

          if result.nil?
            results = instance_eval(&block)
            attributes.each_with_index do |local, index|
              instance_variable_set("@#{local}".to_sym, results[index])
              result = results[index] if local == attribute
            end
          end

          result
        end

        equals_method(attribute)
      end
    end

    def self.equals_method(attribute)
      define_method("#{attribute}=".to_sym) do |result|
        instance_variable_set("@#{attribute}".to_sym, result)
      end
    end

    def title
      @object.name
    end

    def tooltip
      nil
    end

    def image
      nil
    end

    def icon
      nil
    end

    def klass
      nil
    end
{'fraction_non_alphanumeric': 0.08437786609599511, 'fraction_numerical': 0.0, 'mean_word_length': 1.9058614564831262, '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': '1663468', 'n_tokens_mistral': 941, 'n_tokens_neox': 915, 'n_words': 225}