Class: Axiom::Relation::Operation::Group
- Inherits:
-
Axiom::Relation
- Object
- Axiom::Relation
- Axiom::Relation::Operation::Group
- Includes:
- Unary
- Defined in:
- lib/axiom/relation/operation/group.rb
Overview
A class representing a grouped relation
Defined Under Namespace
Modules: Methods
Instance Attribute Summary collapse
-
#attribute ⇒ Attribute::Relation
readonly
private
The grouped attribute.
Attributes included from Operation::Unary
Attributes inherited from Axiom::Relation
Instance Method Summary collapse
-
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set.
-
#initialize(operand, name, attributes) ⇒ undefined
constructor
private
Initialize a grouped relation.
Methods inherited from Axiom::Relation
#==, #[], #directions, #empty?, #include?, #materialize, #materialized?, new, #replace
Methods included from Visitable
Constructor Details
#initialize(operand, name, attributes) ⇒ 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 a grouped relation
28 29 30 31 32 33 34 |
# File 'lib/axiom/relation/operation/group.rb', line 28 def initialize(operand, name, attributes) super(operand) inner = header.project(attributes) @outer = header - inner @attribute = Attribute::Relation.new(name, header: inner) @header = @outer.extend(attribute) end |
Instance Attribute Details
#attribute ⇒ Attribute::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
17 18 19 |
# File 'lib/axiom/relation/operation/group.rb', line 17 def attribute @attribute end |
Instance Method Details
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set
50 51 52 53 54 55 56 57 |
# File 'lib/axiom/relation/operation/group.rb', line 50 def each return to_enum unless block_given? build_index.each do |outer_tuple, inner_tuples| inner_relation = attribute.new_relation(inner_tuples) yield outer_tuple.extend(header, [inner_relation]) end self end |