Class: ReeObject::IsBlank

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_object/package/ree_object/functions/is_blank.rb

Constant Summary collapse

BLANK_RE =
/\A[[:space:]]*\z/
ENCODED_BLANKS =
Concurrent::Map.new do |h, enc|
  h[enc] = Regexp.new(BLANK_RE.source.encode(enc), BLANK_RE.options | Regexp::FIXEDENCODING)
end

Instance Method Summary collapse

Instance Method Details

#call(obj) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/ree_lib/packages/ree_object/package/ree_object/functions/is_blank.rb', line 21

def call(obj)
  return is_string_blank?(obj) if obj.is_a?(String)
  return obj.empty? if obj.is_a?(Array) || obj.is_a?(Hash) || obj.is_a?(Set)
  return true if obj.nil?
  return true if obj == false
  return false if obj == true
  false
end