Class: EnumeratedType
Overview
:title: EnumeratedType
EnumeratedType lets you create enumerated types like this:
class OutputType < EnumeratedType
AUTODETECT
UNKNOWN
NOSOUND
WAVWRITER
DSOUND
WINMM
ASIO
OSS
ALSA
ESD
SOUNDMANAGER
COREAUDIO
XBOX
PS2
GC
XBOX360
PSP
end
If you want to start with a different integer than 0, you can just do:
class OutputType < EnumeratedType
start 15
AUTODETECT
...
end
You can also use start anywhere in the list, to have subsequent constants enumerated starting with the given value.
Author(s)
-
James Buck
Class Method Summary collapse
Class Method Details
.const_missing(sym) ⇒ Object
69 70 71 72 73 |
# File 'lib/mega/enumerated_type.rb', line 69 def const_missing(sym) @next_value ||= 0 const_set(sym, @next_value) @next_value += 1 end |
.start(n) ⇒ Object
65 66 67 |
# File 'lib/mega/enumerated_type.rb', line 65 def start(n) @next_value = n end |