Natural coercion into boolean (true / false). Useful for API interaction.
gem "to_bool"
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:
1is true - TrueClass:
trueis true - Symbol:
:trueis true
See the spec, it pretty much maps it out.
Yes!
ruby spec/to_bool_spec.rb