Class: Toys::Acceptor::Enum
Overview
Defined in the toys-core gem
An acceptor that recognizes a fixed set of values.
You provide a list of valid values. The input argument string will be matched against the string forms of these valid values. If it matches, the converter will return the actual value from the valid list.
For example, you could pass [:one, :two, 3] as the set of values. If
an argument of "two" is passed in, the converter will yield a final
value of the symbol :two. If an argument of "3" is passed in, the
converter will yield the integer 3. If an argument of "three" is
passed in, the match will fail.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(values, type_desc: nil, well_known_spec: nil) ⇒ Enum
constructor
Create an acceptor.
-
#values ⇒ Array<Object>
The array of enum values.
Methods inherited from Base
#convert, #match, #suggestions, #to_s
Constructor Details
#initialize(values, type_desc: nil, well_known_spec: nil) ⇒ Enum
Create an acceptor.
243 244 245 |
# File 'core-docs/toys/acceptor.rb', line 243 def initialize(values, type_desc: nil, well_known_spec: nil) # Source available in the toys-core gem end |
Instance Method Details
#values ⇒ Array<Object>
The array of enum values.
251 252 253 |
# File 'core-docs/toys/acceptor.rb', line 251 def values # Source available in the toys-core gem end |