Class: String
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
41 42 43 |
# File 'lib/reactive_support/core_ext/object/blank.rb', line 41 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
51 52 53 |
# File 'lib/reactive_support/core_ext/object/blank.rb', line 51 def present? !blank? end |