Class: CommandMapper::Types::Enum
- Defined in:
- lib/command_mapper/types/enum.rb
Overview
Represents a mapping of Ruby values to their String equivalents.
Constant Summary
Constants inherited from Map
Map::EnabledDisabled, Map::YesNo
Instance Attribute Summary collapse
-
#values ⇒ Array<Object>
readonly
The values of the enum.
Attributes inherited from Map
Class Method Summary collapse
-
.[](*values) ⇒ Enum
Creates a new enum.
Instance Method Summary collapse
-
#initialize(values) ⇒ Enum
constructor
Initializes the enum type.
Methods inherited from Map
Methods inherited from Type
Constructor Details
#initialize(values) ⇒ Enum
Initializes the enum type.
24 25 26 27 28 |
# File 'lib/command_mapper/types/enum.rb', line 24 def initialize(values) @values = values super(Hash[values.map { |value| [value, value.to_s] }]) end |
Instance Attribute Details
#values ⇒ Array<Object> (readonly)
The values of the enum.
16 17 18 |
# File 'lib/command_mapper/types/enum.rb', line 16 def values @values end |
Class Method Details
.[](*values) ⇒ Enum
Creates a new enum.
39 40 41 |
# File 'lib/command_mapper/types/enum.rb', line 39 def self.[](*values) new(values) end |