<commit_before>module DCPU16
  class Memory
    def initialize(data)
      @ram = Array.new (0x10000 - data.size)
      @ram.insert 0, *data   
    end

    def fetch(index)
      @ram[index]
    end

    def fetch_integer(index)
      fetch(index).unpack("B*").first.to_i 2
    end

    def insert(index, value)
      @ram[index] = value
    end

    def insert_integer(index, value)
      insert(index, [value].pack("S"))
    end
    
    def raw
      @ram
    end

    def self.to_i(word)
      word.unpack("B*").first.to_i 2
    end

    def self.to_bin(int)
      [int].pack("S>")
    end
<commit_msg>Simplifies Memory and remove some unused methods<commit_after>module DCPU16
  class Memory
    def initialize(data)
      @ram = Array.new (0x10000 - data.size)
      @ram.insert 0, *data   
    end

    def fetch(index)
      @ram[index]
    end

    def insert(index, value)
      value = Memory.to_bin(value) if value.is_a? Integer
      @ram[index] = value
    end
    
    def raw
      @ram
    end

    def self.to_i(word)
      word.unpack("B*").first.to_i 2
    end

    def self.to_bin(int)
      [int].pack("S>")
    end

{'fraction_non_alphanumeric': 0.11676909569798069, 'fraction_numerical': 0.018437225636523266, 'mean_word_length': 2.0481283422459895, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5726922', 'n_tokens_mistral': 429, 'n_tokens_neox': 405, 'n_words': 96}