I have seen the solution to pad a number on each side of a decimal, in ruby, but not both on the same time.
here are the pieces I have:
mysize = 5000.127
f1_mysize = "%.2f" % mysize
puts f1_mysize
mysize2 = 5000.8
f2_mysize = "%06d" % mysize2
puts f2_mysize
I can't seem to put the two of those together, in one line. This number is a size, in GB, and I want to make sure the progress messages are lined evenly, so they are easier to read.
Can anyone help me with how to put those together?
Thanks!
You can do both if you ask for it:
The notation here is
%0N.Mf
where N represents how many places overall, and M for places after the decimal. This is based on the classicprintf
-style arguments explained in the documentation.