From 9d892d0228e34cc9335d06aba32b7f1837936682 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Thu, 23 Apr 2015 22:33:25 -0400 Subject: [PATCH] finally make negative work the drunk way --- app.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app.rb b/app.rb index 069bab1..39d7090 100644 --- a/app.rb +++ b/app.rb @@ -67,18 +67,19 @@ def players end def readable_number(value) - #negative = false + negative = false - #negative = true if value.to_f < 0 - #value = value * -1 if value < 0 + negative = true if value.to_f < 0 + value *= -1 if value < 0 numbers.each do |number, symbol| if value.to_f / number.to_f > 1 - return sprintf('%.2f', value.to_f / number.to_f) + '' + symbol + '' + new_value = '-' if negative + new_value += sprintf('%.2f', value.to_f / number.to_f) + '' + symbol + '' + return new_value end end - #value = 0.0 unless value - #value = value * -1 if negative + value = 0.0 unless value return sprintf('%.2f', value) + "_" end