<commit_before>require 'singleton'

class TimerModule
  class Manager
    include Singleton
    
    # register a class as an external module
    def register(category, name, instance)
      @modules = Hash.new if !@modules
      @modules[category] = Hash.new if !@modules.key? category
      @modules[category][name] = instance
    end
    
    def [](category)
      return if !@modules
      @modules[category]
    end
  end
end<commit_msg>Reworked how modules are organized internally a bit.<commit_after>require 'singleton'

class TimerModule
  class Manager
    include Singleton
    
    # register a class as an external module
    def register(category, name, instance)
      @modules = Hash.new if !@modules
      @modules[category] = Collection.new if !@modules.key? category
      @modules[category][name] = instance
    end
    
    def [](category)
      return if !@modules
      @modules[category]
    end
  end

  class Collection
    def initialize
      @members = Hash.new
      puts "Initializing new module collection."
    end

    def +(instance)
      @members[@members.length] = instance
    end

    def []=(name, instance)
      @members[name] = instance
      puts "Collection item #{name} set to #{instance}."
    end
  end
end
{'fraction_non_alphanumeric': 0.08989657915672236, 'fraction_numerical': 0.0, 'mean_word_length': 2.7218934911242605, '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': '6465231', 'n_tokens_mistral': 358, 'n_tokens_neox': 352, 'n_words': 117}