Class: String
Constant Summary collapse
- CAT_BLANK_RE =
/\A[[:space:]]*\z/
Instance Method Summary collapse
-
#blank? ⇒ true, false
A string is blank if it’s empty or contains whitespaces only:.
- #is_caterpillar_json? ⇒ Boolean
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
114 115 116 |
# File 'lib/core_ext/blank.rb', line 114 def blank? CAT_BLANK_RE === self end |
#is_caterpillar_json? ⇒ Boolean
2 3 4 5 6 |
# File 'lib/core_ext/string.rb', line 2 def is_caterpillar_json? JSON.parse(self) rescue false end |