Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxim/ternary_types
Provides ternary singletons True, False, and Maybe with ==,!,&,|,^ operators implemented according to three-value logic.
https://github.com/maxim/ternary_types
Last synced: 4 days ago
JSON representation
Provides ternary singletons True, False, and Maybe with ==,!,&,|,^ operators implemented according to three-value logic.
- Host: GitHub
- URL: https://github.com/maxim/ternary_types
- Owner: maxim
- License: mit
- Created: 2014-12-28T09:18:03.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T18:46:37.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T06:47:51.383Z (6 days ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ternary_types
Use True/False/Maybe singletons to evaluate 3-value logic for such great fun.
## Usage
```irb
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 # => #
T ^ T # => #include TernaryTypes::Coersion
Ternary(true) # => #
Ternary(:foo) # => #Ternary(false) # => #
Ternary(nil) # => #Ternary(:maybe) # => #
```## Installation
Add this line to your application's Gemfile:
```ruby
gem 'ternary_types'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install ternary_types
## Contributing
1. Fork it ( https://github.com/[my-github-username]/ternary_types/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request