Class: Axiom::Algebra::Intersection

Inherits:
Relation
  • Object
show all
Includes:
Relation::Operation::Set
Defined in:
lib/axiom/algebra/intersection.rb

Overview

The intersection between relations

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Operation::Binary

#left, #right

Attributes inherited from Relation

#header

Instance Method Summary collapse

Methods included from Relation::Operation::Set

#initialize

Methods included from Relation::Operation::Binary

#initialize

Methods included from Operation::Binary

#initialize

Methods inherited from Relation

#==, #[], #directions, #empty?, #include?, #initialize, #materialize, #materialized?, new, #replace

Methods included from Visitable

#accept

Instance Method Details

#delete(other) ⇒ Intersection

Delete a relation from the Intersection

Examples:

new_relation = intersection.delete(other)

Parameters:

Returns:



54
55
56
# File 'lib/axiom/algebra/intersection.rb', line 54

def delete(other)
  left.delete(other).intersect(right.delete(other))
end

#each {|tuple| ... } ⇒ self

Iterate over each tuple in the set

Examples:

intersection = Intersection.new(left, right)
intersection.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the set

Returns:

  • (self)


24
25
26
27
28
# File 'lib/axiom/algebra/intersection.rb', line 24

def each
  return to_enum unless block_given?
  left.each { |tuple| yield tuple if right.include?(tuple) }
  self
end

#insert(other) ⇒ Intersection

Insert a relation into the Intersection

Examples:

new_relation = intersection.insert(other)

Parameters:

Returns:



40
41
42
# File 'lib/axiom/algebra/intersection.rb', line 40

def insert(other)
  left.insert(other).intersect(right.insert(other))
end