Project

bools

0.0
No release in over a year
Write one method and bools will test all input combinations
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

bools

bools is a small Ruby gem that makes it easy to evaluate boolean conditionals.

Howto

Just require 'bools' and write a method called test that accepts one or more boolean values. Process those values and return a boolean. A table will be output which shows all the possible input values and their results. The total number of combinations of input variables will be dynamically calculated based on the arity of the test method.

Examples

This small file:

require 'bools'

def test(a, b, c)
  a == c
end

Produces the following:

a b c | result
------+-------
0 0 0 | 1
0 0 1 | 1
0 1 0 | 0
0 1 1 | 0
1 0 0 | 1
1 0 1 | 1
1 1 0 | 0
1 1 1 | 0

Notice that 3 booleans are checked, since there are 3 input variables.

Why?

Many times when coding, it is necessary to process multiple conditionals in order to return a desired result. This can get pretty tedious when trying to calculate all combinations by hand. This library allows you to define a single method, called test, supply however many input booleans you need, define the logic that returns the final result, and display everything in a small table.