This gem convert 'true' and 'false' from string class to collectively TrueClass and FalseClass.
gem install to-bool
You can convert by 'to_bool' method.
'true'.to_bool => TrueClass
'false'.to_bool => FalseClass
In case of already Boolean Type, this method return as it is.
true.to_bool => TrueClass
false.to_bool => FalseClass
- This gems sendback Error for other Object without True/False/String.
- This gems sendback Error for irregular string type(not equal 'true' or 'false')
'truetrue'.to_bool => ArgumentError
''.to_bool => ArgumentError
nil.to_bool => NoMethodError
If you would like to contribute, please...
- Fork.
- Make changes in a branch & add unit tests.
- Run Unit Test
rspec spec/to_bool_spec.rb
- Create a pull request.
Contributions, improvements, comments and suggestions are welcome!
The gem is available as open source under the terms of the MIT License.