module CalendariumRomanum::Enum
Each Enum
encapsulates a finite set of value objects.
@api private
Attributes
all[R]
Returns all contained value objects
@return [Array]
Public Instance Methods
values(index_by: nil) { || ... }
click to toggle source
@api private @param index_by
specifies which value objects' property contains unique internal identifier for use with {.[]}
# File lib/calendarium-romanum/enum.rb, line 14 def values(index_by: nil) defined?(@indexed) && raise(RuntimeError.new('initialized repeatedly')) @all = yield.freeze @all.each &:freeze @indexed = {} @all.each_with_index do |val, i| key = index_by ? val.public_send(index_by) : i @indexed[key] = val end @indexed.freeze end