Mega Code Archive

 
Categories / Ruby / String
 

Center, left justify and right justify string

s = "Some text." s.center(15)                    # => "  Some text.   " s.ljust(15)                     # => "Some text.     " s.rjust(15)                     # => "     Some text."