Project

be_boolean

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Cast number or string to boolean
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
~> 0.11.3
~> 2.0.1
~> 3.0
 Project Readme

BeBoolean

A simple gem for casting strings and numbers to a boolean

Usage

  require 'be_boolean'

  BeBoolean.get(nil) # => false
  BeBoolean.get(0) # => false
  BeBoolean.get("0") # => false
  BeBoolean.get("") # => false
  BeBoolean.get("n") # => false
  BeBoolean.get("N") # => false
  BeBoolean.get("f") # => false
  BeBoolean.get("F") # => false
  BeBoolean.get("false") # => false
  BeBoolean.get("FALSE") # => false

  BeBoolean.get(1) # => true
  BeBoolean.get("1") # => true
  BeBoolean.get("t") # => true
  BeBoolean.get("T") # => true
  BeBoolean.get("true") # => true
  BeBoolean.get("TRUE") # => true
  BeBoolean.get("y") # => true
  BeBoolean.get("Y") # => true
  BeBoolean.get("yes") # => true
  BeBoolean.get("YES") # => true

Copyright

Copyright (c) 2014 Sebastian Porto. See LICENSE.txt for further details.