Class String
In: lib/loquacious/core_ext/string.rb
Parent: Object

Methods

gutter   gutter!   indent   reduce  

Public Instance methods

Removes a leading gutter from all lines in the string. The gutter is defined leading whitespace followed by a single pipe character. This method is very useful with heredocs.

Removes a leading gutter from all lines in the string. The gutter is defined leading whitespace followed by a single pipe character. This method is very useful with heredocs.

The string will be altered by this method.

Indent the string by the given number of spaces. Alternately, if a leader string is given it will be used to indent with instead of spaces. Indentation is performed at the beginning of the string and after every newline character.

  "foo\nbar".indent( 2 )    #=> "  foo\n  bar"

Reduce the size of the current string to the given width by removing characters from the middle of the string and replacing them with ellipses. If the width is greater than the length of the string, the string is returned unchanged. If the width is less than the length of the ellipses, then the ellipses are returned.

[Validate]