Class: Conditions::RegexCondition

Inherits:
BaseCondition show all
Defined in:
lib/conditions.rb

Overview

Compares a value against a regular expression

Instance Method Summary collapse

Constructor Details

#initialize(predicate) ⇒ 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