Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Overview
from activesupport/lib/active_support/core_ext/object/blank.rb
Constant Summary collapse
- BLANK_REGEX =
/\A[[:space:]]*\z/
Instance Method Summary collapse
-
#blank? ⇒ true, false
A string is blank if it’s empty or contains whitespaces only:.
Instance Method Details
#blank? ⇒ true, false
A string is blank if it’s empty or contains whitespaces only:
''.blank? # => true
' '.blank? # => true
"\t\n\r".blank? # => true
' blah '.blank? # => false
Unicode whitespace is supported:
"\u00a0".blank? # => true
18 19 20 |
# File 'lib/core_ext/string.rb', line 18 def blank? BLANK_REGEX === self end |