Class: Transformers::ExplicitEnum
- Inherits:
-
Object
- Object
- Transformers::ExplicitEnum
- Defined in:
- lib/transformers/utils/generic.rb
Direct Known Subclasses
AggregationStrategy, ChannelDimension, ClassificationFunction, PaddingStrategy, TensorType, TruncationStrategy
Instance Method Summary collapse
-
#initialize(value) ⇒ ExplicitEnum
constructor
A new instance of ExplicitEnum.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ ExplicitEnum
Returns a new instance of ExplicitEnum.
47 48 49 50 51 52 53 |
# File 'lib/transformers/utils/generic.rb', line 47 def initialize(value) expected = self.class.constants.map { |k| self.class.const_get(k) } unless expected.include?(value) raise ArgumentError, "#{value} is not a valid #{self.class.name}, please select one of #{expected.inspect}" end @value = value end |
Instance Method Details
#to_s ⇒ Object
55 56 57 |
# File 'lib/transformers/utils/generic.rb', line 55 def to_s @value end |