Triad
A Triad is like a Set, or a collection of three-part arrays.
A Triad is a collection of items each with a key
, descriptor
, and value
.
Each key
must be a unique symbol.
Each descriptor
must be a string.
Each value
must not be a symbol nor a string.
user = Object.new
map = Triad.new
map << [:admin, 'Admin', user]
map.keys('Admin') #=> [:admin]
map.values('Admin') #=> [user]
map.descriptors('Admin') #=> ['Admin']
# or raise Triad::ItemNotPresent
map.descriptors(user) #=> ['Admin']
map.keys(user) #=> [:admin]
map.values(user) #=> [user]
# or raise Triad::ItemNotPresent
map.values(:admin) #=> [user]
map.descriptors(:admin) #=> ['Admin']
map.keys(:admin) #=> [:admin]
# or raise Triad::ItemNotPresent
map.each do |key, descriptor, value|
#...
end
Installation
Add this line to your application's Gemfile:
gem 'triad'
And then execute:
$ bundle
Or install it yourself as:
$ gem install triad
Contributing
- Fork it
- 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 new Pull Request