1
0

Added rounding and not displaying 0

This commit is contained in:
cryptogopher 2020-04-28 16:26:14 +02:00
parent 3418af87c1
commit 9f3f90e4f0

View File

@ -7,8 +7,10 @@ module BodyTrackersHelper
when amount.nan?
'?'
else
unit_desc = unit != mfu_unit ? unit && " [#{unit.shortname}]" || ' [-]' : ''
"%.#{precision}f%s" % [amount, unit_desc]
a = amount.round(precision)
a_desc = a.nonzero? ? "%.#{precision}f" % a : '-'
u_desc = unit && " [#{unit.shortname}]" || ' [-]' if unit != mfu_unit && a.nonzero?
"#{a_desc}#{u_desc}"
end
end