Class: Factbase::Rules::Later

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

Overview

Check one fact (never complaining).

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

Instance Method Summary collapse

Constructor Details

#initialize(uid) ⇒ Later

Returns a new instance of Later.



134
135
136
137
# File 'lib/factbase/rules.rb', line 134

def initialize(uid)
  @uid = uid
  @facts = Set.new
end

Instance Method Details

#include?(fact) ⇒ Boolean

Returns:

  • (Boolean)


147
148
149
150
151
152
153
# File 'lib/factbase/rules.rb', line 147

def include?(fact)
  return true if @uid.nil?
  a = fact[@uid]
  return true if a.nil?
  raise "More than one #{@uid.inspect} in the fact: #{a}" if a.size > 1
  @facts.include?(a.first)
end

#it(fact, _fb) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/factbase/rules.rb', line 139

def it(fact, _fb)
  return if @uid.nil?
  a = fact[@uid]
  return if a.nil?
  raise "More than one #{@uid.inspect} in the fact: #{a}" if a.size > 1
  @facts << a.first
end