Last Updated: February 25, 2016
·
6.16K
· dwradcliffe

Pad number with leading zeros

Easy way to pad an integer with leading zeros in Ruby:

"%03d" % an_int

http://www.ruby-doc.org/core-1.9.3/String.html#method-i-25