This is my personal library I use to share the Ruby tidbits I made it for my various projects
Add this line to your application's Gemfile:
gem 'ruby-tidbits', git: 'https://github.com/konoplev-roman/ruby-tidbits'And then execute:
$ bundle
To use bool extensions, add to the top of your file:
require 'tidbits/bool'
You can now use
.to_boolonNilClass,String,Numeric,FalseClassandTrueClass.to_iforFalseClassandTrueClass
Example:
nil.to_bool
# => false
'yes'.to_bool
# => true
'no'.to_bool
# => false
1.to_bool
# => true
0.to_bool
# => false
false.to_bool
# => false
false.to_i
# => 0
false.to_bool
# => true
true.to_i
# => 1
Bug reports and pull requests are welcome on GitHub at https://github.com/konoplev-roman/ruby-tidbits. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Ruby::Tidbits project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.