diff options
| author | a14m <[email protected]> | 2020-11-29 23:32:06 +0100 |
|---|---|---|
| committer | a14m <[email protected]> | 2020-11-29 23:32:06 +0100 |
| commit | 5555d4122fb96a2d52a887fbffa365c709056986 (patch) | |
| tree | 40ccf13f6e44989d8c84d090ddd783890b8d933c /CLI/ruby/lib | |
| parent | 8f88de4e158681f6321ecb2348005424108e2bd9 (diff) | |
Add the basic cell representation object
Diffstat (limited to 'CLI/ruby/lib')
| -rw-r--r-- | CLI/ruby/lib/game_of_life.rb | 1 | ||||
| -rw-r--r-- | CLI/ruby/lib/game_of_life/cell.rb | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/CLI/ruby/lib/game_of_life.rb b/CLI/ruby/lib/game_of_life.rb index c2e6845..7f70933 100644 --- a/CLI/ruby/lib/game_of_life.rb +++ b/CLI/ruby/lib/game_of_life.rb @@ -2,6 +2,7 @@ require "game_of_life/version" require "game_of_life/universe" +require "game_of_life/cell" module GameOfLife class Error < StandardError; end 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 |
