From 602d200b9fd0ebde60a2391ffd6bb2408689f3a5 Mon Sep 17 00:00:00 2001 From: a14m Date: Sat, 30 Jan 2021 16:10:55 +0100 Subject: Fix Living/Dead cells can have more than 1 char or have the same char --- CLI/ruby/lib/game_of_life.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CLI/ruby/lib') 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 -- cgit v1.2.3