Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bools

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bools

  • 0.5.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 30 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc