From 8995a601675463bbe809c3460693521492193f5c Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Mon, 13 Nov 2017 12:09:32 -0500 Subject: [PATCH] Clean up case statement in trucolor.cr --- lib/trucolor.cr | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/lib/trucolor.cr b/lib/trucolor.cr index b9b779c6..a8005420 100644 --- a/lib/trucolor.cr +++ b/lib/trucolor.cr @@ -34,24 +34,15 @@ module Trucolor f = n - 43 * h t = f * 255 / 43 q = 255 - t - case h - when 0 - return {255, t, 0} - when 1 - return {q, 255, 0} - when 2 - return {0, 255, t} - when 3 - return {0, q, 255} - when 4 - return {t, 0, 255} - when 5 - return {255, 0, q} - else - return {0, 0, 0} + when 0; return {255, t, 0} + when 1; return {q, 255, 0} + when 2; return {0, 255, t} + when 3; return {0, q, 255} + when 4; return {t, 0, 255} + when 5; return {255, 0, q} end - + return {0, 0, 0} end # Tests the format method by printing a rainbow of colors