Class: Wongi::Engine::AnyRule

Inherits:
Object
  • Object
show all
Defined in:
lib/wongi-engine/dsl/any_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AnyRule

Returns a new instance of AnyRule.



6
7
8
9
10
11
# File 'lib/wongi-engine/dsl/any_rule.rb', line 6

def initialize &block
  @variants = []
  if block
    instance_eval &block
  end
end

Instance Attribute Details

#variantsObject (readonly)

Returns the value of attribute variants.



4
5
6
# File 'lib/wongi-engine/dsl/any_rule.rb', line 4

def variants
  @variants
end

Instance Method Details

#import_into(rete) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/wongi-engine/dsl/any_rule.rb', line 19

def import_into rete
  AnySet.new variants.map { |variant|
    if variant.respond_to? :import_into
      variant.import_into(rete)
    else
      variant
    end
  }
end

#option(&block) ⇒ Object



13
14
15
16
17
# File 'lib/wongi-engine/dsl/any_rule.rb', line 13

def option &block
  var = VariantRule.new
  var.instance_eval &block
  variants << var
end