Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ bools Public

Ruby gem to easily check multiple boolean conditionals

License

Notifications You must be signed in to change notification settings

shreeve/bools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Ruby gem to easily check multiple boolean conditionals

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages