From 1dc14ac2456475ea72ab9affb938034c817ede29 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 25 Apr 2015 13:08:47 -0400 Subject: [PATCH] Finally fix negative to work with positive --- app.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app.rb b/app.rb index 7305ef0..9d07fc8 100644 --- a/app.rb +++ b/app.rb @@ -67,17 +67,17 @@ def players end def readable_number(value) - #if value.to_f < 0 - # negative = true - # value *= -1 if value < 0 - #else - # negative = false - #end + if value.to_f < 0 + negative = true + value *= -1 if value < 0 + else + negative = false + end numbers.each do |number, symbol| - if value.to_f / number.to_f > 1 - #new_value = '-' if negative - new_value = sprintf('%.2f', value.to_f / number.to_f) + '' + symbol + '' + if value.to_f / number.to_f >= 1 + new_value = negative ? '-' : '' + new_value += sprintf('%.2f', value.to_f / number.to_f) + '' + symbol + '' return new_value end end