class Conwy::Cell

Public Class Methods

new(alive:) click to toggle source
# File lib/conwy/cell.rb, line 3
def initialize(alive:)
  @alive = alive
end

Public Instance Methods

alive?() click to toggle source
# File lib/conwy/cell.rb, line 7
def alive?
  @alive
end
next(alive_neighbors:) click to toggle source
# File lib/conwy/cell.rb, line 11
def next(alive_neighbors:)
  if alive_neighbors == 3 || (alive? && alive_neighbors == 2)
    self.class.new(alive: true)
  else
    self.class.new(alive: false)
  end
end