class CellularAutomata::Cell

Attributes

alive[R]
alive?[R]
column[R]
row[R]
x[R]
y[R]

Public Class Methods

new(alive: false, row: , column:) click to toggle source
# File lib/cellular_automata/cell.rb, line 6
def initialize(alive: false, row: , column:)
  @alive = alive
  @row = row
  @column = column
end

Public Instance Methods

copy() click to toggle source
# File lib/cellular_automata/cell.rb, line 32
def copy
  self.class.new(alive: alive?, row: row, column: column)
end
dead?() click to toggle source
# File lib/cellular_automata/cell.rb, line 28
def dead?
  !alive?
end
die!() click to toggle source
# File lib/cellular_automata/cell.rb, line 21
def die!
  @alive = false
end
live!() click to toggle source
# File lib/cellular_automata/cell.rb, line 17
def live!
  @alive = true
end
survive!() click to toggle source
# File lib/cellular_automata/cell.rb, line 25
def survive!
end
to_s() click to toggle source
# File lib/cellular_automata/cell.rb, line 12
def to_s
  return ' ' if dead?
  '*'
end