Class: CalendariumRomanum::Enum
- Inherits:
-
Object
- Object
- CalendariumRomanum::Enum
show all
- Extended by:
- Forwardable
- Defined in:
- lib/calendarium-romanum/enum.rb
Overview
Utility class for definition of enumerated “types”
Class Method Summary
collapse
Class Method Details
.all ⇒ Object
25
26
27
|
# File 'lib/calendarium-romanum/enum.rb', line 25
def all
@all
end
|
.values(index_by: nil, &blk) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/calendarium-romanum/enum.rb', line 9
def values(index_by: nil, &blk)
defined?(@indexed) && raise(RuntimeError.new('initialized repeatedly'))
@indexed = {}
@all = yield.freeze
@all.each_with_index do |val, i|
val.freeze
key = index_by ? val.public_send(index_by) : i
@indexed[key] = val
end
@indexed.freeze
end
|