Simple Enum in Ruby
Enums are under appreciated in the Ruby eco-system. I was looking the other day for an Enum implementation and went through the Ruby Standard Library and was expecting to find something.
Sure, i was disappointed that i didn't find anything (why?) but decided to give it a shot and to create this Enum gist.
a short feature list:
- Inherits from Ruby's Set to ensure a uniqueness of Enum members
- A class implementation for Enum::Member that has attributes for the enum member symbol, string value (name) and the enum index.
- Enum::Member is equipped with Ruby's Comparable to allow fun comparison methods between Enum members.
Written by Elad Meidar
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#