diff options
| author | a14m <[email protected]> | 2021-01-30 16:10:55 +0100 |
|---|---|---|
| committer | a14m <[email protected]> | 2021-01-30 16:10:55 +0100 |
| commit | 602d200b9fd0ebde60a2391ffd6bb2408689f3a5 (patch) | |
| tree | 73832ef271c277aa317e7bf81e51336fbd88b425 /CLI/ruby/lib/game_of_life.rb | |
| parent | d1fc54d9c8e10f0aced6de3c275bf494f6867abf (diff) | |
Fix Living/Dead cells can have more than 1 char or have the same char
Diffstat (limited to 'CLI/ruby/lib/game_of_life.rb')
| -rw-r--r-- | CLI/ruby/lib/game_of_life.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/CLI/ruby/lib/game_of_life.rb b/CLI/ruby/lib/game_of_life.rb index a2ce27a..2ff548c 100644 --- a/CLI/ruby/lib/game_of_life.rb +++ b/CLI/ruby/lib/game_of_life.rb @@ -43,6 +43,14 @@ module GameOfLife "must be between 1 and #{max_height} (current terminal height)" end + fail GameOfLife::Error, "Invalid --live-cell value. must be a single character" if options["live-cell"].length > 1 + + fail GameOfLife::Error, "Invalid --dead-cell value. must be a single character" if options["dead-cell"].length > 1 + + if options["dead-cell"] == options["live-cell"] + fail GameOfLife::Error, "Invalid --dead-cell value. must be a different character than --live-cell" + end + { # Defaults the hight to less then the height of the terminal to allow banner info # and an extra emtpy line to avoid triggering terminal scroll while flushing |
