Class: Ruleby::Core::Fact

Inherits:
Object
  • Object
show all
Defined in:
lib/core/engine.rb

Overview

A fact is an object that is stored in working memory. The rules in the system will either look for the existence or absence of particular facts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, token) ⇒ Fact



112
113
114
115
# File 'lib/core/engine.rb', line 112

def initialize(object, token)
  @token = token      
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



110
111
112
# File 'lib/core/engine.rb', line 110

def object
  @object
end

#recencyObject

Returns the value of attribute recency.



109
110
111
# File 'lib/core/engine.rb', line 109

def recency
  @recency
end

#tokenObject

Returns the value of attribute token.



108
109
110
# File 'lib/core/engine.rb', line 108

def token
  @token
end

Instance Method Details

#==(fact) ⇒ Object



121
122
123
# File 'lib/core/engine.rb', line 121

def ==(fact)
  return fact != nil && fact.id == id
end

#idObject



117
118
119
# File 'lib/core/engine.rb', line 117

def id
  return object.object_id
end

#to_sObject



125
126
127
# File 'lib/core/engine.rb', line 125

def to_s
  return "[Fact |#{@recency}|#{@object.to_s}]"
end