If you use ActiveSupport
you have access to the method #presence
that returns nil if the object is #blank?
require "active_support"
# blank? on String is a regex for /[:space:]*/
"\n\t \n\r".presence
=> nil
" abc ".presence
=> " abc "