Sha256: e6977bffa74efb87da301470c9f0b08a73f28bdcd5f367fb84338ffbac8af1c0
Contents?: true
Size: 851 Bytes
Versions: 3
Compression:
Stored size: 851 Bytes
Contents
require 'command_mapper/types/map' module CommandMapper module Types # # Represents a mapping of Ruby values to their String equivalents. # class Enum < Map # The values of the enum. # # @return [Array<Object>] # # @api semipublic # attr_reader :values # # Initializes the enum type. # # @param [Array<Object>] values # The values of the enum type. # def initialize(values) @values = values super(Hash[values.map { |value| [value, value.to_s] }]) end # # Creates a new enum. # # @param [Array<Object>] values # List of enum values. # # @return [Enum] # The newly created enum object. # def self.[](*values) new(values) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
command_mapper-0.3.1 | lib/command_mapper/types/enum.rb |
command_mapper-0.3.0 | lib/command_mapper/types/enum.rb |
command_mapper-0.2.1 | lib/command_mapper/types/enum.rb |