String.strip!

Signature

string.strip!   #=> string or nil

String.strip! is the in-place edit version of
String.strip.
string.strip! returns string with leading and trailing whitespace removed
from string or it returns nil if no leading or trailing whitespace was found.

Examples

str = "\r\n\t  foo bar  \r\n\t"   #=> "\r\n\t  foo bar  \r\n\t"
str.strip!                        #=> "foo bar"
str == "\r\n\t  foo bar  \r\n\t"  #=> false
str == "foo bar"                  #=> true
str.strip!                        #=> nil

Documentation Reference

www.ruby-doc.org : String.strip!