<commit_before>module Rulers
  module Model
    class FileModel
      def initialize(filename)
        @filename = filename

        # if filename is 37.json @id is 37
        basename = File.split(filename)[-1]
        @id = File.basename(basename, ".json").to_i

        obj = File.read(filename)
        @hash = MultiJson.decode(obj)
      end

      def [](name)
        @hash[name.to_s]
      end

      def []=(name, value)
        @hash[name.to_s] = value
      end

      def self.find(id)
        begin
          FileModel.new("db/quotes/#{id}.json")
        rescue
          raise "FileModel not found"
        end
      end
    end
  end
end<commit_msg>added all method to FileModel class<commit_after>module Rulers
  module Model
    class FileModel
      def initialize(filename)
        @filename = filename

        # if filename is 37.json @id is 37
        basename = File.split(filename)[-1]
        @id = File.basename(basename, ".json").to_i

        obj = File.read(filename)
        @hash = MultiJson.decode(obj)
      end

      def [](name)
        @hash[name.to_s]
      end

      def []=(name, value)
        @hash[name.to_s] = value
      end

      def self.find(id)
        begin
          FileModel.new("db/quotes/#{id}.json")
        rescue
          raise "FileModel not found"
        end
      end

      def self.all
        files = Dir["db/quotes/*.json"]
        files.map { |f| FileModel.new f }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10807113543091655, 'fraction_numerical': 0.006839945280437756, 'mean_word_length': 1.6942909760589318, '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': '2609702', 'n_tokens_mistral': 476, 'n_tokens_neox': 458, 'n_words': 115}