<commit_before>module ListBase

  def empty?
    @head.nil?
  end

  def to_s(separator=', ')
    buffer = []
    each_node do |node|
      buffer << node.to_s
    end
    "[#{buffer.join(separator)}]"
  end

  def inspect
    buffer = []
    each_node do |node|
      buffer << node.inspect
    end
    "LinkedList ##{object_id} [\n#{buffer.join(",\n")}]"
  end

  private

  def each_node
    if block_given?
      current = @head
      until current.nil?
        yield current
        current = current.next
      end
    else
      raise "Method each_node needs a block"
    end
  end

end<commit_msg>add abstract method 'starting_node' to ListBase module (use it instead of object var @head)<commit_after>module ListBase

  def empty?
    @head.nil?
  end

  def starting_node
    raise NotImplementedError, "You must implement method 'starting_node' in #{self.class.name} class"
  end

  def to_s(separator=', ')
    buffer = []
    each_node do |node|
      buffer << node.to_s
    end
    "[#{buffer.join(separator)}]"
  end

  def inspect
    buffer = []
    each_node do |node|
      buffer << node.inspect
    end
    "LinkedList ##{object_id} [\n#{buffer.join(",\n")}]"
  end

  private

  def each_node
    if block_given?
      current = starting_node
      until current.nil?
        yield current
        current = current.next
      end
    else
      raise "Method each_node needs a block"
    end
  end

end
{'fraction_non_alphanumeric': 0.10378681626928471, 'fraction_numerical': 0.0, 'mean_word_length': 2.3341121495327104, 'pattern_counts': {'":': 0, '<': 11, '<?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': '2984968', 'n_tokens_mistral': 479, 'n_tokens_neox': 462, 'n_words': 133}