Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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