Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ioquatix/boolean
Useful methods for working with Booleans
https://github.com/ioquatix/boolean
Last synced: 20 days ago
JSON representation
Useful methods for working with Booleans
- Host: GitHub
- URL: https://github.com/ioquatix/boolean
- Owner: ioquatix
- License: mit
- Created: 2011-02-16T00:04:49.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-12-11T23:52:47.000Z (almost 7 years ago)
- Last Synced: 2024-10-04T18:24:38.807Z (about 1 month ago)
- Language: Ruby
- Homepage: http://rubygems.org/gems/boolean
- Size: 8.79 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: LICENSE.txt
Awesome Lists containing this project
README
h1. Boolean -- Additional Boolean-related core extensions
| *Author* | Tim Morgan |
| *Version* | 1.0 (Feb 15, 2011) |
| *License* | Released under the MIT license. |h2. About
*Boolean* adds some helpful methods for working with Ruby's Boolean types,
@TrueClass@ and @FalseClass@ (the singleton classes whose only instances are
@true@ and @false@, respectively).With *Boolean*, you get a @Boolean@ mixin so you can refer to @true@ and @false@
under a common class name:
if variable.kind_of?(Boolean) then
[ ... ]
endYou can also type-cast Ruby objects into their Boolean values:
"string".to_bool #=> true
nil.to_bool #=> falseAnd you can parse various Ruby objects to Booleans:
"yes".parse_bool #=> true
"no".parse_bool #=> false
1.parse_bool => true
0.parse_bool => false(@parse_bool@ is also aliased as @to_b@ to be consistent with the
@to_i@/@to_int@ naming paradigm.)Lastly, inline with the @Integer()@ method, you have a @Boolean()@ method:
Boolean("yes") #=> true
Boolean("no") #=> false
Boolean("maybe") #=> ArgumentErrorh2. Installation and Usage
Just add the gem to your project's @Gemfile@:
gem 'boolean'All the features shown in the previous section are now available in your project
code.More information can be found in the class and method documentation.