<commit_before>module Atlas
  # Base class for representing resources.
  class Resource
    attr_accessor :tag, :url_builder

    def initialize(tag, hash = {})
      @tag = tag
      @url_builder = UrlBuilder.new tag

      hash.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
    end

    def update_with_response(o, except_keys = [])
      hash = JSON.parse(o)

      # remove keys that shouldn't be included
      except_keys.each { |k| hash.delete(k) }

      hash.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
    end

    def to_hash
      attrs = instance_variables.map { |v| v.to_s.sub(/^@/, '') }
      Hash[attrs.select { |v| respond_to? v }.map { |v| [v.to_sym, send(v)] }]
    end

    def inspect
      objects = to_hash.map { |k, v| "#{k}=#{v.inspect}" }.join(' ')
      "#<#{self.class.name}:#{object_id} #{objects}>"
    end
  end
end<commit_msg>Hides the tag, url_builder from the output.<commit_after>module Atlas
  # Base class for representing resources.
  class Resource
    attr_accessor :tag, :url_builder

    def initialize(tag, hash = {})
      @tag = tag
      @url_builder = UrlBuilder.new tag

      hash.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
    end

    def update_with_response(o, except_keys = [])
      hash = JSON.parse(o)

      # remove keys that shouldn't be included
      except_keys.each { |k| hash.delete(k) }

      hash.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
    end

    def to_hash
      attrs = instance_variables.collect do |v|
        %w(@tag @url_builder).include?(v.to_s) ? next : v.to_s.sub(/^@/, '')
      end.compact!

      Hash[attrs.select { |v| respond_to? v }.map { |v| [v.to_sym, send(v)] }]
    end

    def inspect
      objects = to_hash.map { |k, v| "#{k}=#{v.inspect}" }.join(' ')
      "#<#{self.class.name}:#{object_id} #{objects}>"
    end
  end
end
{'fraction_non_alphanumeric': 0.18026666666666666, 'fraction_numerical': 0.0, 'mean_word_length': 2.714851485148515, 'pattern_counts': {'":': 0, '<': 5, '<?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': '771490', 'n_tokens_mistral': 700, 'n_tokens_neox': 694, 'n_words': 166}