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.
190 |
# File 'lib/shellopts/argument_type.rb', line 190 def initialize(values) @values = values.dup end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
189 190 191 |
# File 'lib/shellopts/argument_type.rb', line 189 def values @values end |
Instance Method Details
#match?(name, literal) ⇒ Boolean
191 |
# File 'lib/shellopts/argument_type.rb', line 191 def match?(name, literal) value?(literal) or "Illegal value - #{literal}" end |
#value?(value) ⇒ Boolean
192 |
# File 'lib/shellopts/argument_type.rb', line 192 def value?(value) @values.include?(value) end |