Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Existence

Lightweight presence and blank checks for Ruby without ActiveSupport.

Installation

gem "existence"

Usage

Extends the following classes with presence and blank checks.

Array

[].present?        # => false
["a"].present?     # => true
[].blank?          # => true
["a"].blank?       # => false

Hash

{}.present?        # => false
{ a: 1 }.present?  # => true
{}.blank?          # => true
{ a: 1 }.blank?    # => false

String

Blank if empty or whitespace-only.

"".present?        # => false
"hello".present?   # => true
"  ".blank?        # => true
"hello".blank?     # => false

Numeric

All numbers are present, including zero.

0.present?         # => true
1.present?         # => true
0.blank?           # => false
1.blank?           # => false

Symbol

:foo.present?      # => true
:foo.blank?        # => false

NilClass

nil.present?       # => false
nil.blank?         # => true

TrueClass / FalseClass

true.present?      # => true
true.blank?        # => false
false.present?     # => false
false.blank?       # => true

About

Lightweight presence and blank checks for Ruby without ActiveSupport.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages