Class: Toys::Definition::PatternAcceptor
- Defined in:
- lib/toys/definition/acceptor.rb
Overview
An acceptor that uses a regex to validate input.
Instance Attribute Summary
Attributes inherited from Acceptor
Instance Method Summary collapse
-
#initialize(name, regex, converter = nil, &block) ⇒ PatternAcceptor
constructor
Create a pattern acceptor.
-
#match(str) ⇒ Object
Overrides Acceptor#match to use the given regex.
Methods inherited from Acceptor
Constructor Details
#initialize(name, regex, converter = nil, &block) ⇒ PatternAcceptor
Create a pattern acceptor.
You must provide a regular expression as a validator. You may also provide a converter proc. See Acceptor for details on the converter.
137 138 139 140 |
# File 'lib/toys/definition/acceptor.rb', line 137 def initialize(name, regex, converter = nil, &block) super(name, converter, &block) @regex = regex end |
Instance Method Details
#match(str) ⇒ Object
Overrides Acceptor#match to use the given regex.
145 146 147 |
# File 'lib/toys/definition/acceptor.rb', line 145 def match(str) @regex.match(str) end |