# TITLE: # # String Blank Extension # # SUMMARY: # # String blank extensions. # # CREDIT: # # - Martin Pool # - Alan Davies # - Derek Lewis # - Peter Vanbroekhoven # # TODO: # # - Does #blank? really belong here? # class String # Is this string just whitespace? # # "abc".blank? #=> false # " ".blank? #=> true def blank? self !~ /\S/ end alias whitespace? blank? end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TestStringBlank < Test::Unit::TestCase def test_blank? assert( ! "xyz".blank? ) assert( " ".blank? ) end def test_whitespace? assert( ! "xyz".whitespace? ) assert( " ".whitespace? ) end end =end