title: How can I output leading zeros in Ruby?
body: <p>I'm outputting a set of numbered files from a Ruby script. The numbers come from incrementing a counter, but to make them sort nicely in the directory, I'd like to use leading zeros in the filenames. In other words</p>
  
  <blockquote>
    <p>file_001...</p>
  </blockquote>
  
  <p>instead of</p>
  
  <blockquote>
    <p>file_1</p>
  </blockquote>
  
  <p>Is there a <strong>simple</strong> way to add leading zeros when converting a number to a string? (I know I can do "if less than 10.... if less than 100").</p>