Path: | lib/eymiha/util/enum.rb |
Last Update: | Wed May 07 16:12:06 -0400 2008 |
Enums are used to build a sets of enumerated values.
Numeric and bitwise enums are provided, and include provisions for assigned values and the allowance of gaps.
enum %w(N1 N2 +2 N3 N4 =7 N5 N6 3 N7)
gives N1 = 0, N2 = 1, N3 = 4, N4 = 5, N5 = 7, N6 = 8 and N7 = 3
enum_bitwise %w(B1 B2 +2 B3 B4 =7 B5 B6 3 B7)
gives B1 = 1, B2 = 2, B3 = 16, B4 = 32, B5 = 128, B6 = 256 and B7 = 8