Module: OMF::Rete

Defined in:
lib/omf_rete.rb,
lib/omf_rete/tuple.rb,
lib/omf_rete/join_op.rb,
lib/omf_rete/version.rb,
lib/omf_rete/tuple_stream.rb,
lib/omf_rete/planner/plan_set.rb,
lib/omf_rete/indexed_tuple_set.rb,
lib/omf_rete/planner/join_plan.rb,
lib/omf_rete/abstract_tuple_set.rb,
lib/omf_rete/planner/filter_plan.rb,
lib/omf_rete/planner/source_plan.rb,
lib/omf_rete/planner/plan_builder.rb,
lib/omf_rete/planner/abstract_plan.rb,
lib/omf_rete/planner/plan_level_builder.rb

Defined Under Namespace

Modules: Planner, Store Classes: AbstractTupleSet, AbstractTupleStream, FilterTupleStream, IndexedTupleSet, JoinOP, ProcessingTupleStream, ResultTupleStream, Tuple

Constant Summary collapse

VERSION =
'0.6.2'
TOP_DIR =

Used for finding the example directory

File.dirname(File.dirname(File.dirname(__FILE__)))

Class Method Summary collapse

Class Method Details

.create_engine(opts = {}) ⇒ Object

Create a Rete engine to operate on.

Parameters:

  • opts (defaults to: {})

    :tuple_length Length of tuple if only one type is used



11
12
13
14
15
# File 'lib/omf_rete.rb', line 11

def self.create_engine(opts = {})
  require 'omf_rete/store'
  Store.create(opts.delete(:tuple_length), opts)

end

.differ(binding1, binding2) ⇒ Object



38
39
40
41
42
# File 'lib/omf_rete.rb', line 38

def self.differ(binding1, binding2)
  filter(binding1, binding2) do |b1, b2|
    b1 != b2
  end
end

.filter(*projectPattern, &block) ⇒ Object

Defines a filter on a tuple stream. The argument is either a variable number of binding variables with which the associated block is called. If the argument are two arrays, the first one holds the above described bindings for the block, while the second one describes the tuple returned by the block.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omf_rete.rb', line 23

def self.filter(*projectPattern, &block)
  require 'omf_rete/planner/filter_plan'
  if projectPattern[0].kind_of? Array
    if projectPattern.size != 2
      raise "Wrong arguments for 'filter'. See documentation."
    end
    outDescription = projectPattern[1]
    projectPattern = projectPattern[0]
  else
    outDescription = nil
  end

  FilterPlan.new(projectPattern, outDescription, &block)
end