Class: Conditions::RegexCondition
- Inherits:
-
BaseCondition
- Object
- BaseCondition
- Conditions::RegexCondition
- Defined in:
- lib/conditions.rb
Overview
Compares a value against a regular expression
Instance Method Summary collapse
- #apply(value) ⇒ true, false
-
#initialize(predicate) ⇒ RegexCondition
constructor
A new instance of RegexCondition.
Constructor Details
#initialize(predicate) ⇒ RegexCondition
Returns a new instance of RegexCondition.
47 48 49 50 51 52 |
# File 'lib/conditions.rb', line 47 def initialize(predicate) predicate = Regexp.new(predicate.to_s) super(predicate) rescue RegexpError => e raise ConditionError, e.inspect end |
Instance Method Details
#apply(value) ⇒ true, false
58 59 60 |
# File 'lib/conditions.rb', line 58 def apply(value) @predicate.match?(value) end |