Class: Command::RegexpArgument

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

Overview

Input must match the regular expression passed to create this Argument

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, regex) ⇒ RegexpArgument

Returns a new instance of RegexpArgument.



155
156
157
158
# File 'lib/command-set/arguments.rb', line 155

def initialize(name, regex)
  super(name)
  @regex = regex
end

Instance Method Details

#complete(prefix, subject) ⇒ Object



160
161
162
# File 'lib/command-set/arguments.rb', line 160

def complete(prefix, subject)
  return [prefix]
end

#validate(term, subject) ⇒ Object



164
165
166
# File 'lib/command-set/arguments.rb', line 164

def validate(term, subject)
  return @regex =~ term
end