Skip to content

Natural coercion from any object into boolean values in Ruby

License

Notifications You must be signed in to change notification settings

bricker/to_bool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToBool

Natural coercion into boolean (true / false). Useful for API interaction.

Installation

gem "to_bool"

Usage

Call to_bool or to_boolean on any object. It will usually return false, except:

  • String: "t", "true", "1", "y", and "yes" are true
  • Integer: 1 is true
  • TrueClass: true is true
  • Symbol: :true is true

See the spec, it pretty much maps it out.

Contributing

Yes!

Running Tests

ruby spec/to_bool_spec.rb

About

Natural coercion from any object into boolean values in Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages