Sathish Manohar Sathish Manohar - 11 months ago 58
Ruby Question

How to align ruby string to left or right?

I have few ruby strings, which I want to align left and right appropriately.

I'm now using

"Name".center(20, " ")
to get
"(7 spaces)Name(8 spaces)"

How can I achieve
"Name(15 spaces)"
"(15 spaces)Name"


Answer Source