Class: String
Overview
Instance Method Summary collapse
-
#blank? ⇒ Boolean
When called on a string, the
#blank?method returnstrueif the string is empty or consists only of whitespace: ”.blank? # => true “ n ”.blank? # => true ‘foo’.blank? # => false. -
#present? ⇒ Boolean
When called on a string, the
#present?method returnstrueunless the string is empty or consists only of whitespace: ‘foo’.present? # => true ”.present? # => false ‘ ’.present? # => false.
Instance Method Details
#blank? ⇒ Boolean
When called on a string, the #blank? method returns true if the string is empty or consists only of whitespace:
''.blank? # => true
" \n ".blank? # => true
'foo'.blank? # => false
18 19 20 |
# File 'lib/reactive_support/core_ext/object/blank.rb', line 18 def blank? !!(/\A[[:space:]]*\z/ =~ self) || self.empty? end |
#present? ⇒ Boolean
When called on a string, the #present? method returns true unless the string is empty or consists only of whitespace:
'foo'.present? # => true
''.present? # => false
' '.present? # => false
28 29 30 |
# File 'lib/reactive_support/core_ext/object/blank.rb', line 28 def present? !blank? end |