Project

to_bool

0.37
Low commit activity in last 3 years
No release in over a year
Super-simple gem that extends some Ruby classes with a "to_bool" method, which converts any object naturally into a boolean.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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