Class: Command::ArrayArgument

Inherits:
Argument
  • Object
show all
Defined in:
lib/command-set/arguments.rb

Overview

Created with an array of options to choose from

Instance Attribute Summary

Attributes inherited from Argument

#name, #value

Instance Method Summary collapse

Methods inherited from Argument

#check_present, #consume, #consume_hash, #match_terms, #omittable?, #parse, register, #required?

Constructor Details

#initialize(name, array) ⇒ ArrayArgument

Returns a new instance of ArrayArgument.



318
319
320
321
# File 'lib/command-set/arguments.rb', line 318

def initialize(name, array)
  super(name)
  @options = array
end

Instance Method Details

#complete(prefix, subject) ⇒ Object



323
324
325
# File 'lib/command-set/arguments.rb', line 323

def complete(prefix, subject)
  return @options.grep(%r{^#{prefix}.*})
end

#validate(term, subject) ⇒ Object



327
328
329
# File 'lib/command-set/arguments.rb', line 327

def validate(term, subject)
  return @options.include?(term)
end