Class: Predicate::Criterion
- Defined in:
- lib/carat-dev/predicate/predicate.rb
Overview
Criterion is a psuedo-method probe
Instance Attribute Summary collapse
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#matches ⇒ Object
Returns the value of attribute matches.
Instance Method Summary collapse
-
#initialize(exp) ⇒ Criterion
constructor
A new instance of Criterion.
- #match(value) ⇒ Object
Constructor Details
#initialize(exp) ⇒ Criterion
Returns a new instance of Criterion.
18 19 20 21 |
# File 'lib/carat-dev/predicate/predicate.rb', line 18 def initialize(exp) @expression = exp @matches = [] end |
Instance Attribute Details
#expression ⇒ Object
Returns the value of attribute expression.
17 18 19 |
# File 'lib/carat-dev/predicate/predicate.rb', line 17 def expression @expression end |
#matches ⇒ Object
Returns the value of attribute matches.
17 18 19 |
# File 'lib/carat-dev/predicate/predicate.rb', line 17 def matches @matches end |
Instance Method Details
#match(value) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/carat-dev/predicate/predicate.rb', line 22 def match( value ) if @expression.is_a?(Regexp) @matches << value if value =~ @expression else @matches << value if value == @expression end end |