Finally fix negative to work with positive

This commit is contained in:
Andrew Tomaka 2015-04-25 13:08:47 -04:00
parent 65c8c701f0
commit 1dc14ac245

18
app.rb
View file

@ -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) + '<strong>' + symbol + '</strong>'
if value.to_f / number.to_f >= 1
new_value = negative ? '-' : ''
new_value += sprintf('%.2f', value.to_f / number.to_f) + '<strong>' + symbol + '</strong>'
return new_value
end
end