Class: EacRubyUtils::Enum

Inherits:
Object show all
Defined in:
lib/eac_ruby_utils/enum.rb

Overview

Defined Under Namespace

Classes: Value

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#keyObject (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

Raises:

  • (::ArgumentError)


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

.valuesObject



19
20
21
# File 'lib/eac_ruby_utils/enum.rb', line 19

def values
  value_set.map(&:value)
end