Class: OMF::Rete::AbstractTupleStream

Inherits:
Object
  • Object
show all
Defined in:
lib/omf_rete/tuple_stream.rb

Overview

This class provides functionality to process a stream of tuples.

Direct Known Subclasses

ProcessingTupleStream, ResultTupleStream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, source = nil) ⇒ AbstractTupleStream

Returns a new instance of AbstractTupleStream.



13
14
15
16
# File 'lib/omf_rete/tuple_stream.rb', line 13

def initialize(description, source = nil)
  @description = description
  @source = source
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#sourceObject

Returns the value of attribute source.



10
11
12
# File 'lib/omf_rete/tuple_stream.rb', line 10

def source
  @source
end

Instance Method Details

#check_for_tuple(tuple) ⇒ Object

Return true if tuple can be produced by this stream through the normal (addTuple) channels.



27
28
29
# File 'lib/omf_rete/tuple_stream.rb', line 27

def check_for_tuple(tuple)
  raise "Method 'check_for_tuple' is not implemented"
end

#describe(out = STDOUT, offset = 0, incr = 2, sep = "\n") ⇒ Object



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

def describe(out = STDOUT, offset = 0, incr = 2, sep = "\n")
  out.write(" " * offset)
  _describe(out, sep)
  if @source
    @source.describe(out, offset + incr, incr, sep)
  end
end

#detachObject

Detach all streams from each other as they are no longer in use



33
34
35
36
# File 'lib/omf_rete/tuple_stream.rb', line 33

def detach()
  @source.detach if @source
  @source = nil
end

#index_for_binding(bname) ⇒ Object



18
19
20
21
22
# File 'lib/omf_rete/tuple_stream.rb', line 18

def index_for_binding(bname)
  @description.find_index do |el|
    el == bname
  end
end