Class: Predicate::Criterion

Inherits:
Object show all
Defined in:
lib/carat-dev/predicate/predicate.rb

Overview

Criterion is a psuedo-method probe

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#expressionObject

Returns the value of attribute expression.



17
18
19
# File 'lib/carat-dev/predicate/predicate.rb', line 17

def expression
  @expression
end

#matchesObject

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