<commit_before>module Plaid
  class Category
    attr_accessor :type, :hierarchy, :id

    class << self
      # API: semi-private
      # This method takes an array returned from the API and instantiates
      # all of the categories
      def all(res)
        res.map { |cat| self.build(cat) }
      end

      # API: semi-private
      # This method instantiates and builds a single category
      def build(res)
        self.new.update(res)
      end
    end

    # API: semi-private
    # This method updates a Plaid:Category based upon the results from the API
    def update(cat)
      self.type = cat['type']
      self.hierarchy = cat['hierarchy']
      self.id = cat['id']
      return self
    end
  end
end<commit_msg>Fix category parsing.<commit_after>module Plaid
  class Category
    attr_accessor :type, :hierarchy, :id

    def initialize(type, hierarchy, id)
      @type = type
      @hierarchy = hierarchy
      @id = id
    end

    # API: semi-private
    # This method takes an array returned from the API and instantiates all of the categories
    def self.all(res)
      res.map { |cat| build(cat) }
    end

    # API: semi-private
    # This method instantiates and builds a single category
    def self.build(cat)
      new(cat['type'], cat['hierarchy'], cat['id'])
    end
  end
end
{'fraction_non_alphanumeric': 0.08854961832061069, 'fraction_numerical': 0.0, 'mean_word_length': 2.4140625, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5497640', 'n_tokens_mistral': 401, 'n_tokens_neox': 389, 'n_words': 136}