Class: Command::ArrayArgument
- Defined in:
- lib/command-set/arguments.rb
Overview
Created with an array of options to choose from
Instance Attribute Summary
Attributes inherited from Argument
Instance Method Summary collapse
- #complete(prefix, subject) ⇒ Object
-
#initialize(name, array) ⇒ ArrayArgument
constructor
A new instance of ArrayArgument.
- #validate(term, subject) ⇒ Object
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) = 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 .grep(%r{^#{prefix}.*}) end |
#validate(term, subject) ⇒ Object
327 328 329 |
# File 'lib/command-set/arguments.rb', line 327 def validate(term, subject) return .include?(term) end |