Class: ShellOpts::Grammar::EnumArgument
- Inherits:
-
ArgumentType
- Object
- ArgumentType
- ShellOpts::Grammar::EnumArgument
- Defined in:
- lib/shellopts/argument_type.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from ArgumentType
Instance Method Summary collapse
-
#initialize(values) ⇒ EnumArgument
constructor
A new instance of EnumArgument.
- #match?(name, literal) ⇒ Boolean
- #value?(value) ⇒ Boolean
Methods inherited from ArgumentType
Constructor Details
#initialize(values) ⇒ EnumArgument
Returns a new instance of EnumArgument.
133 |
# File 'lib/shellopts/argument_type.rb', line 133 def initialize(values) @values = values.dup end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
132 133 134 |
# File 'lib/shellopts/argument_type.rb', line 132 def values @values end |
Instance Method Details
#match?(name, literal) ⇒ Boolean
134 |
# File 'lib/shellopts/argument_type.rb', line 134 def match?(name, literal) value?(literal) or "Illegal value in #{name}: '#{literal}'" end |
#value?(value) ⇒ Boolean
135 |
# File 'lib/shellopts/argument_type.rb', line 135 def value?(value) @values.include?(value) end |