summaryrefslogtreecommitdiffstats
path: root/CLI/ruby/lib/game_of_life
diff options
context:
space:
mode:
authora14m <[email protected]>2020-11-29 23:32:06 +0100
committera14m <[email protected]>2020-11-29 23:32:06 +0100
commit5555d4122fb96a2d52a887fbffa365c709056986 (patch)
tree40ccf13f6e44989d8c84d090ddd783890b8d933c /CLI/ruby/lib/game_of_life
parent8f88de4e158681f6321ecb2348005424108e2bd9 (diff)
Add the basic cell representation object
Diffstat (limited to 'CLI/ruby/lib/game_of_life')
-rw-r--r--CLI/ruby/lib/game_of_life/cell.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/CLI/ruby/lib/game_of_life/cell.rb b/CLI/ruby/lib/game_of_life/cell.rb
new file mode 100644
index 0000000..fe52263
--- /dev/null
+++ b/CLI/ruby/lib/game_of_life/cell.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module GameOfLife
+ class Cell
+ attr_accessor :alive
+
+ # Initialize a cell in the game of life universe
+ # @param alive [True|False] boolean indicating if the cell is considered alive
+ def initialize(alive:)
+ @alive = alive
+ end
+
+ # Representation of a cell
+ # @return [String] if a cell is alive or an empty space
+ def to_s
+ return @alive ? "\u2588" : "\s"
+ end
+ end
+end