Class: Tibber::Enum
- Inherits:
-
Object
- Object
- Tibber::Enum
- Defined in:
- lib/tibber/const.rb
Overview
The ‘Enum` class provides a way to define constant-based enumerations dynamically.
Direct Known Subclasses
Class Method Summary collapse
-
.enum(array) ⇒ Object
Defines constants from an array of symbols or strings.
Class Method Details
.enum(array) ⇒ Object
Defines constants from an array of symbols or strings.
The above example dynamically defines constants ‘RED`, `GREEN`, and `BLUE` inside the `Colors` class.
18 19 20 21 22 |
# File 'lib/tibber/const.rb', line 18 def self.enum(array) array.each do |cnst| const_set cnst, cnst end end |