Class: ShellOpts::Grammar::EnumArgument

Inherits:
ArgumentType show all
Defined in:
lib/shellopts/argument_type.rb

Instance Attribute Summary collapse

Attributes inherited from ArgumentType

#message

Instance Method Summary collapse

Methods inherited from ArgumentType

#convert, #name, #to_s

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

#valuesObject (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

Returns:

  • (Boolean)


191
# File 'lib/shellopts/argument_type.rb', line 191

def match?(name, literal) value?(literal) or set_message "Illegal value - #{literal}" end

#value?(value) ⇒ Boolean

Returns:

  • (Boolean)


192
# File 'lib/shellopts/argument_type.rb', line 192

def value?(value) @values.include?(value) end