Rubenum
Rubenum allows you to create simple enumerations in Ruby.
Installation
You can install the Rubenum gem via gem install rubenum.
Usage
Create an enumeration from an array of strings with Rubenum.new.
Only valid Ruby identifiers are accepted.
By default, every element will be capitalized in order to make valid Ruby constant identifiers.
Arguments
- elements (array of string) : array containing the elements of the enumeration
- upcase (optional boolean (default:false)) : true => upcase elements' name instead of capitalizing them
- binary_values (optional boolean (default:false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
Example
e = Rubenum.new(%w[red orange green])
puts e::Orange # => 2