class Wongi::Engine::DSL::Rule
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 31 def initialize name @name = name @current_section = nil Rule.sections.each { |section| acceptors[section] ||= [] } end
section(s, *aliases)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 11 def section s, *aliases unless sections.include?(s) sections << s define_method s do |&d| @current_section = s instance_eval &d end aliases.each { |a| alias_method a, s } end end
sections()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 22 def sections @sections ||= [] end
Public Instance Methods
acceptors()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 37 def acceptors @acceptors ||= {} end
actions()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 49 def actions acceptors[:make] ||= [] end
actions=(a)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 53 def actions= a acceptors[:make] = a end
conditions()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 41 def conditions acceptors[:forall] ||= [] end
conditions=(c)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 45 def conditions= c acceptors[:forall] = c end
import_into(rete)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 57 def import_into rete self.class.new( @name ).tap do |copy| copy.conditions = conditions copy.actions = actions.map do |action| if action.respond_to? :import_into action.import_into(rete) else action end end end end
install( rete )
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 71 def install( rete ) rete.install_rule( self ) end
Protected Instance Methods
accept(stuff)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 77 def accept stuff acceptors[@current_section] << stuff end