Ruby has all the standard print formatters, available either via printf, sprintf or using 'formatstring' % [var1, ...]
.
>> '%.2f' % 3.14159 #=> "3.14"
>> '%4s %-4s' % ['foo', 'bar'] #=> " foo bar "
Ruby has all the standard print formatters, available either via printf, sprintf or using 'formatstring' % [var1, ...]
.
>> '%.2f' % 3.14159 #=> "3.14"
>> '%4s %-4s' % ['foo', 'bar'] #=> " foo bar "