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 28 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 7 def section(s, *aliases) return if sections.include?(s) sections << s define_method s do |&d| @current_section = s section = DSL.sections[s].new section.rule = self section.instance_eval(&d) end aliases.each { |a| alias_method a, s } end
sections()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 20 def sections @sections ||= [] end
Public Instance Methods
accept(stuff)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 72 def accept(stuff) acceptors[@current_section] << stuff end
acceptors()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 34 def acceptors @acceptors ||= {} end
actions()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 46 def actions acceptors[:make] ||= [] end
actions=(a)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 50 def actions=(a) acceptors[:make] = a end
conditions()
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 38 def conditions acceptors[:forall] ||= [] end
conditions=(c)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 42 def conditions=(c) acceptors[:forall] = c end
import_into(rete)
click to toggle source
# File lib/wongi-engine/dsl/rule.rb, line 54 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 68 def install(rete) rete.install_rule(self) end