Simple Ruby library determining whether strings indicate truey or falsy values.
to-be is a library providing facilities for determining the truthyness of strings. It is implemented in several languages: to_be.Ruby is the Ruby implementation.
It has no dependencies on any other non-standard library.
Install via gem as in:
gem install to_be
or add it to your Gemfile.
Use via require, as in:
require'to_be'to_be.Ruby provides:
- module functions
ToBe.string_falsey?,ToBe.string_truey?, andToBe.string_truthy?; - String extensions
#falsey?,#truey?, and#truthy?viarequire 'to_be/extensions/string';
The term "truthy" is an unhelpfully overloaded term in the programming world, insofar as it is used to refer to the notion of "truthyness" - whether something can be deemed to be interpretable as truth - and also the true side of that interpretation. In this library, the former interpretation is used, leaving us with the following terms:
- "truthy" - whether something can be deemed to be interpretable as having truth;
- "falsey" - whether an object can be deemed to be interpretable as being false;
- "truey" - whether an object can be deemed to be interpretable as being true;
For example, consider the following Ruby program:
require'to_be's1="no"s2="True"s3="orange"# "no" is validly truthy, and is falseyToBe.string_falsey?(s1)# => trueToBe.string_truey?(s1)# => falseToBe.string_truthy?(s1)# => true# "True" is validly truthy, and is trueyToBe.string_falsey?(s2)# => falseToBe.string_truey?(s2)# => trueToBe.string_truthy?(s2)# => true# "orange" is not validly truthy, and is neither falsey nor trueyToBe.string_falsey?(s3)# => falseToBe.string_truey?(s3)# => falseToBe.string_truthy?(s3)# => falseand, if extensions are used, the following Ruby program:
require'to_be/extensions/string's1="no"s2="True"s3="orange"# "no" is validly truthy, and is falseys1.falsey?# => trues1.truey?# => falses1.truthy?# => true# "True" is validly truthy, and is trueys2.falsey?# => falses2.truey?# => trues2.truthy?# => true# "orange" is not validly truthy, and is neither falsey nor trueys3.falsey?# => falses3.truey?# => falses3.truthy?# => falseExamples are provided in the examples directory, along with a markdown description for each. A detailed list TOC of them is provided in EXAMPLES.md.
Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/to_be.Ruby.
Libraries upon which to_be.Ruby depends:
- <none>;
Projects that depend on to_be.Ruby:
- <none>;
- <none>;
- py2be (Python);
- to-be (C);
- to-be.Go;
- to-be.Rust;
to_be.Ruby is released under the 3-clause BSD license. See LICENSE for details.