<commit_before>require "dir_friend/version"

module DirFriend
  # Your code goes here...
end<commit_msg>Paste F and D classes in DirFriend<commit_after>require "dir_friend/version"

module DirFriend
  class F
    attr_reader :name, :path, :level
    def initialize(name, level=0)
      @name = File.basename(name)
      @path = File.expand_path(name)
      @level = level
    end

    def to_s
      "F: #{name}"
    end
  end

  class D < F
    attr_reader :entries
    def initialize(name, level=0, depth=Float::MAX.to_i)
      super(name, level)
      @entries = []
      build(depth) if depth >= 1
      self
    end

    def <<(file)
      @entries << file
    end

    def each(&blk)
      entries.each do |e|
        blk.call(e)
        e.each(&blk) if e.is_a?(D)
      end
    end

    def to_s
      "D: #{name} => [#{entries.join(', ')}]"
    end

    private
    def build(depth)
      entries = Dir[File.join(path, '*')]
      entries.each do |ent|
        self << begin
          File.directory?(ent) ? D.new(ent, level+1, depth-1) : F.new(ent, level+1)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12929475587703435, 'fraction_numerical': 0.0054249547920434, 'mean_word_length': 2.1271186440677967, 'pattern_counts': {'":': 0, '<': 10, '<?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': '6672439', 'n_tokens_mistral': 395, 'n_tokens_neox': 386, 'n_words': 101}