Class: EacRubyUtils::Enum
Overview
Similar to Java’s enum type (docs.oracle.com/javase/tutorial/java/javaOO/enum.html).
Defined Under Namespace
Classes: Value
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
30 31 32 |
# File 'lib/eac_ruby_utils/enum.rb', line 30 def key @key end |
Class Method Details
.enum(key, *args, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/eac_ruby_utils/enum.rb', line 9 def enum(key, *args, &block) value = Value.new(self, key, args, &block) raise ::ArgumentError, "#{self} already has a value with key=#{value.key}" if value_set.include?(value) value_set << value.apply self end |
.values ⇒ Object
19 20 21 |
# File 'lib/eac_ruby_utils/enum.rb', line 19 def values value_set.map(&:value) end |