Module: CalendariumRomanum::Enum Private
- Extended by:
- Forwardable
- Defined in:
- lib/calendarium-romanum/enum.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Each Enum encapsulates a finite set of value objects.
Instance Attribute Summary collapse
-
#all ⇒ Array
readonly
private
Returns all contained value objects.
Instance Method Summary collapse
-
#[](identifier) ⇒ Object
Value object or nil.
- #each { ... } ⇒ void
- #values(index_by: nil) ⇒ Object private
Instance Attribute Details
#all ⇒ Array (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all contained value objects
33 34 35 |
# File 'lib/calendarium-romanum/enum.rb', line 33 def all @all end |
Instance Method Details
#[](identifier) ⇒ Object
Returns value object or nil.
48 |
# File 'lib/calendarium-romanum/enum.rb', line 48 def_delegators :@indexed, :[] |
#each { ... } ⇒ void
This method returns an undefined value.
40 |
# File 'lib/calendarium-romanum/enum.rb', line 40 def_delegators :@all, :each |
#values(index_by: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/calendarium-romanum/enum.rb', line 14 def values(index_by: nil) 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 |