Last Updated: February 25, 2016
·
1.598K
· eladmeidar

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.