0.0
No release in over a year
Returns a boolean based on the given argument.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

Kernel#Boolean

Returns a boolean based on the given argument.

Status

Version Yard documentation Ruby License

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

License

The gem is available as open source under the terms of the MIT License.