main
 1class Printer
 2  def initialize(max_x)
 3    @max_x = max_x
 4  end
 5
 6  def display(world)
 7    clear
 8    world.each_with_index do |cell, index|
 9      print cell.alive? ? "X" : " "
10      puts if (index+1) % @max_x == 0
11    end
12    sleep 1
13  end
14
15  private
16
17  def clear
18    puts "\e[H\e[2J"
19  end
20end