Rubyists,
I think a fine companion for String#ljust, String#rjust and
String#center would be String#indent.
For example:
text = <<EOT
I must go down to the sea again
The lonely sea and sky
And all I want is a tall ship
And a star to steer me by
EOT
text.indent(4) == <<EOT # -> true
I must go down to the sea again
The lonely sea and sky
And all I want is a tall ship
And a star to steer me by
EOT
text.indent("-+- ") == <<EOT # -> true
-+- I must go down to the sea again
-+- The lonely sea and sky
-+- And all I want is a tall ship
-+- And a star to steer me by
EOT
Note that the above code is demonstration only; I haven't run it.
It would probably be better in hindsight to move #ljust et al into a
separate module (StringFormat, say) with which individual objects can
be extended at will. Then more and more utility methods can be added
without bloating String.
Gavin