Kernel#Boolean
Returns a boolean based on the given argument.
Status
Installation
Add this line to your application's Gemfile:
gem "kernel-boolean"
And then execute:
bundle install
Or install it yourself as:
gem install kernel-boolean
Usage
If the argument is true
, returns true
.
If the argument is false
, returns false
.
In all other cases, returns an error.
Example
require "kernel/boolean"
Boolean(false) # => false
Boolean(true) # => true
Boolean(nil) # => TypeError: can't convert nil into boolean
Boolean("true") # => ArgumentError: invalid value for Boolean(): "true"
Note
The #Boolean
method could be used similarly to the methods already present in the Kernel
module:
#Array
#Complex
#Float
#Hash
#Integer
#Rational
#String
Warning
The Kernel
module is included in the Object
class, so by loading this library, the #Boolean
method will be available in every Ruby object.
Versioning
Kernel#Boolean
uses Semantic Versioning 2.0.0
See also
-
kernel-symbol
: Returns aSymbol
based on the given argument.
License
The gem is available as open source under the terms of the MIT License.