<commit_before>module Systemd
  class JournalEntry
    include Enumerable

    attr_reader :fields

    def initialize(entry)
      @entry  = entry
      @fields = entry.map do |key, value|
        name = key.downcase.to_sym
        define_singleton_method(name){ value } unless respond_to?(name)
        name
      end

    end

    def [](key)
      @entry[key] || @entry[key.to_s.upcase]
    end

    def each<commit_msg>document JournalEntry a bit.<commit_after>module Systemd
  # Represents a single entry in the Journal.
  class JournalEntry
    include Enumerable

    attr_reader :fields

    # Create a new JournalEntry from the given entry hash. You probably don't
    # need to construct this yourself; instead instances are returned from
    # {Systemd::Journal} methods such as {Systemd::Journal#current_entry}.
    # @param [Hash] entry a hash containing all the key-value pairs associated
    #   with a given journal entry.
    def initialize(entry)
      @entry  = entry
      @fields = entry.map do |key, value|
        name = key.downcase.to_sym
        define_singleton_method(name){ value } unless respond_to?(name)
        name
      end

    end

    # Get the value of a given field in the entry, or nil if it doesn't exist
    def [](key)
      @entry[key] || @entry[key.to_s.upcase]
    end

    def each
{'fraction_non_alphanumeric': 0.07894736842105263, 'fraction_numerical': 0.0, 'mean_word_length': 2.6666666666666665, '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': '491455', 'n_tokens_mistral': 397, 'n_tokens_neox': 384, 'n_words': 134}