Class: KBS::AlphaMemory
- Inherits:
-
Object
- Object
- KBS::AlphaMemory
- Defined in:
- lib/kbs/alpha_memory.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#linked ⇒ Object
readonly
Returns the value of attribute linked.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#successors ⇒ Object
Returns the value of attribute successors.
Instance Method Summary collapse
- #activate(fact) ⇒ Object
- #deactivate(fact) ⇒ Object
-
#initialize(pattern = {}) ⇒ AlphaMemory
constructor
A new instance of AlphaMemory.
- #relink! ⇒ Object
- #unlink! ⇒ Object
Constructor Details
#initialize(pattern = {}) ⇒ AlphaMemory
Returns a new instance of AlphaMemory.
8 9 10 11 12 13 |
# File 'lib/kbs/alpha_memory.rb', line 8 def initialize(pattern = {}) @items = [] @successors = [] @pattern = pattern @linked = true end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
5 6 7 |
# File 'lib/kbs/alpha_memory.rb', line 5 def items @items end |
#linked ⇒ Object (readonly)
Returns the value of attribute linked.
6 7 8 |
# File 'lib/kbs/alpha_memory.rb', line 6 def linked @linked end |
#pattern ⇒ Object
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/kbs/alpha_memory.rb', line 5 def pattern @pattern end |
#successors ⇒ Object
Returns the value of attribute successors.
5 6 7 |
# File 'lib/kbs/alpha_memory.rb', line 5 def successors @successors end |
Instance Method Details
#activate(fact) ⇒ Object
25 26 27 28 29 |
# File 'lib/kbs/alpha_memory.rb', line 25 def activate(fact) return unless @linked @items << fact @successors.each { |s| s.right_activate(fact) } end |
#deactivate(fact) ⇒ Object
31 32 33 34 35 |
# File 'lib/kbs/alpha_memory.rb', line 31 def deactivate(fact) return unless @linked @items.delete(fact) @successors.each { |s| s.right_deactivate(fact) if s.respond_to?(:right_deactivate) } end |
#relink! ⇒ Object
20 21 22 23 |
# File 'lib/kbs/alpha_memory.rb', line 20 def relink! @linked = true @successors.each { |s| s.right_relink! if s.respond_to?(:right_relink!) } end |
#unlink! ⇒ Object
15 16 17 18 |
# File 'lib/kbs/alpha_memory.rb', line 15 def unlink! @linked = false @successors.each { |s| s.right_unlink! if s.respond_to?(:right_unlink!) } end |