Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/trak/core_ext/blank.rb

Overview

Constant Summary collapse

NON_WHITESPACE_REGEXP =

0x3000: fullwidth whitespace

%r![^\s#{[0x3000].pack("U")}]!

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

A string is blank if it’s empty or contains whitespaces only:

"".blank?                 # => true
"   ".blank?              # => true
" ".blank?               # => true
" something here ".blank? # => false

Returns:

  • (Boolean)


13
14
15
# File 'lib/trak/core_ext/blank.rb', line 13

def blank?
  self !~ NON_WHITESPACE_REGEXP
end