Class: Featureflow::Conditions

Inherits:
Object
  • Object
show all
Defined in:
lib/featureflow/conditions.rb

Class Method Summary collapse

Class Method Details

.test(op, a, b) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/featureflow/conditions.rb', line 3

def self.test(op, a, b)
  case op
  when 'equals'
    a.eql? b[0]
  when 'contains'
    a.include? b[0]
  when 'startsWith'
    a.start_with? b[0]
  when 'endsWith'
    a.end_with? b[0]
  when 'matches'
    a.match? Regexp.new(b[0])
  when 'in'
    b.include? a
  when 'notIn'
    !b.include? a
  when 'greaterThan'
    a > b[0]
  when 'greaterThanOrEqual'
    a >= b[0]
  when 'lessThan'
    a < b[0]
  when 'lessThanOrEqual'
    a <= b[0]
  when 'before'
    a < b[0]
  when 'after'
    a > b[0]
  else
    false
  end
end