ternary_types
Use True/False/Maybe singletons to evaluate 3-value logic for such great fun.
Usage
require 'ternary_types'
T = TernaryTypes::True.instance
M = TernaryTypes::Maybe.instance
F = TernaryTypes::False.instance
!T
!M
T == F
M == T
M == M
T == T
T & F
M & T
T | F # => #<TernaryTypes::True:0x007feccc7bc670>
T ^ T # => #<TernaryTypes::False:0x007feccc7c4938>
include TernaryTypes::Coersion
Ternary(true) # => #<TernaryTypes::True:0x007feccc7bc670>
Ternary(:foo) # => #<TernaryTypes::True:0x007feccc7bc670>
Ternary(false) # => #<TernaryTypes::False:0x007feccc7c4938>
Ternary(nil) # => #<TernaryTypes::False:0x007feccc7c4938>
Ternary(:maybe) # => #<TernaryTypes::Maybe:0x007feccc7b61f8>
Installation
Add this line to your application's Gemfile:
gem 'ternary_types'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ternary_types
Contributing
- Fork it ( https://github.com/[my-github-username]/ternary_types/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request