Class: KeyVortex::Constraint::Regexp
- Defined in:
- lib/key_vortex/constraint/regexp.rb
Overview
Enforces that strings match the specified pattern. Because regular expressions are too complicated to establish clean bounds, it will not be considered when narrowing based on adapter constraints.
Instance Attribute Summary collapse
-
#pattern ⇒ Regexp
readonly
The regexp the value must match.
Instance Method Summary collapse
-
#accepts?(value) ⇒ Boolean
True if pattern =~ value.
-
#attribute ⇒ Symbol
:regexp.
-
#initialize(pattern) ⇒ Regexp
constructor
A new instance of Regexp.
-
#within?(_) ⇒ true
Regular expressions are too flexible, they cannot be compared.
Methods inherited from Base
Constructor Details
#initialize(pattern) ⇒ Regexp
Returns a new instance of Regexp.
16 17 18 19 |
# File 'lib/key_vortex/constraint/regexp.rb', line 16 def initialize(pattern) super() @pattern = pattern end |
Instance Attribute Details
#pattern ⇒ Regexp (readonly)
Returns The regexp the value must match.
13 14 15 |
# File 'lib/key_vortex/constraint/regexp.rb', line 13 def pattern @pattern end |
Instance Method Details
#accepts?(value) ⇒ Boolean
Returns True if pattern =~ value.
34 35 36 |
# File 'lib/key_vortex/constraint/regexp.rb', line 34 def accepts?(value) pattern =~ value end |
#attribute ⇒ Symbol
Returns :regexp.
22 23 24 |
# File 'lib/key_vortex/constraint/regexp.rb', line 22 def attribute :regexp end |
#within?(_) ⇒ true
Returns Regular expressions are too flexible, they cannot be compared.
28 29 30 |
# File 'lib/key_vortex/constraint/regexp.rb', line 28 def within?(_) true end |