Class: Factbase::Rules::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/rules.rb

Overview

Check one fact.

This is an internal class, it is not supposed to be instantiated directly.

Instance Method Summary collapse

Constructor Details

#initialize(fb, expr) ⇒ Check

Returns a new instance of Check.



123
124
125
126
# File 'lib/factbase/rules.rb', line 123

def initialize(fb, expr)
  @fb = fb
  @expr = expr
end

Instance Method Details

#it(fact) ⇒ Object



128
129
130
131
# File 'lib/factbase/rules.rb', line 128

def it(fact)
  return if Factbase::Syntax.new(@expr).to_term.evaluate(fact, [])
  raise "The fact is in invalid state: #{fact}"
end