Class: Axiom::Relation::Operation::Ungroup

Inherits:
Axiom::Relation show all
Includes:
Unary
Defined in:
lib/axiom/relation/operation/ungroup.rb

Overview

A class representing an ungrouped relation

Defined Under Namespace

Modules: Methods

Instance Attribute Summary collapse

Attributes included from Operation::Unary

#operand

Attributes inherited from Axiom::Relation

#header

Instance Method Summary collapse

Methods inherited from Axiom::Relation

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

Methods included from Visitable

#accept

Constructor Details

#initialize(operand, name) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize an ungrouped relation

Parameters:



27
28
29
30
31
32
# File 'lib/axiom/relation/operation/ungroup.rb', line 27

def initialize(operand, name)
  super(operand)
  @attribute = header[name]
  @outer     = header - [attribute]
  @header    = @outer.extend(attribute.header)
end

Instance Attribute Details

#attributeAttribute::Relation (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The grouped attribute

Returns:



17
18
19
# File 'lib/axiom/relation/operation/ungroup.rb', line 17

def attribute
  @attribute
end

Instance Method Details

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

Iterate over each tuple in the set

Examples:

ungrouped = Ungroup.new(operand, name)
ungrouped.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the set

Returns:

  • (self)


48
49
50
51
52
53
54
55
56
57
# File 'lib/axiom/relation/operation/ungroup.rb', line 48

def each
  return to_enum unless block_given?
  operand.each do |tuple|
    outer_tuple = tuple.project(@outer)
    tuple[attribute].each do |inner_tuple|
      yield outer_tuple.join(header, inner_tuple)
    end
  end
  self
end