Class: Axiom::Algebra::Product

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

Overview

The cartesian product between relations

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Operation::Binary

#left, #right

Attributes inherited from Relation

#header

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Relation::Operation::Combination

combine_tuples

Methods included from Relation::Operation::Binary

#initialize

Methods included from Operation::Binary

#initialize

Methods inherited from Relation

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

Methods included from Visitable

#accept

Class Method Details

.new(left, right) ⇒ Join

Instantiate a new Product

Examples:

product = Product.new(left, right)

Parameters:

Returns:



21
22
23
24
# File 'lib/axiom/algebra/product.rb', line 21

def self.new(left, right)
  assert_disjointed_headers(left, right)
  super
end

Instance Method Details

#deleteundefined

Raise an exception when deleting from the Product

Examples:

product.delete(other)  # => ImmutableRelationError raised

Returns:

  • (undefined)

Raises:



94
95
96
# File 'lib/axiom/algebra/product.rb', line 94

def delete(*)
  raise ImmutableRelationError, 'deleting from a product is impossible'
end

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

Iterate over each tuple in the set

Examples:

product = Product.new(left, right)
product.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the set

Returns:

  • (self)


59
60
61
62
63
64
65
66
# File 'lib/axiom/algebra/product.rb', line 59

def each(&block)
  return to_enum unless block_given?
  util = Relation::Operation::Combination
  left.each do |left_tuple|
    util.combine_tuples(header, left_tuple, right, &block)
  end
  self
end

#insertundefined

Raise an exception when inserting into the Product

Examples:

product.insert(other)  # => ImmutableRelationError raised

Returns:

  • (undefined)

Raises:



79
80
81
# File 'lib/axiom/algebra/product.rb', line 79

def insert(*)
  raise ImmutableRelationError, 'inserting into a product is impossible'
end