Class: Axiom::Algebra::Extension
- Includes:
- Relation::Operation::Unary
- Defined in:
- lib/axiom/algebra/extension.rb
Overview
Extend a relation to include calculated attributes
Defined Under Namespace
Modules: Methods
Instance Attribute Summary collapse
-
#extensions ⇒ Hash
readonly
private
The extensions for the relation.
Attributes included from Operation::Unary
Attributes inherited from Relation
Instance Method Summary collapse
-
#delete(other) ⇒ Extension
Delete a relation from the Extension.
-
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set.
-
#initialize(operand, extensions) ⇒ undefined
constructor
private
Initialize an Extension.
-
#insert(other) ⇒ Extension
Insert a relation into the Extension.
Methods inherited from Relation
#==, #[], #directions, #empty?, #include?, #materialize, #materialized?, new, #replace
Methods included from Visitable
Constructor Details
#initialize(operand, extensions) ⇒ 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 Extension
28 29 30 31 32 33 |
# File 'lib/axiom/algebra/extension.rb', line 28 def initialize(operand, extensions) super(operand) keys = extensions.keys @header = @header.extend(keys) @extensions = Hash[@header.project(keys).zip(extensions.values)] end |
Instance Attribute Details
#extensions ⇒ Hash (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 extensions for the relation
16 17 18 |
# File 'lib/axiom/algebra/extension.rb', line 16 def extensions @extensions end |
Instance Method Details
#delete(other) ⇒ Extension
Delete a relation from the Extension
The other relation must be a matching extension.
91 92 93 94 |
# File 'lib/axiom/algebra/extension.rb', line 91 def delete(other) assert_matching_extensions(other, DELETED) operand.delete(other.operand).extend(extensions) end |
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set
49 50 51 52 53 54 |
# File 'lib/axiom/algebra/extension.rb', line 49 def each return to_enum unless block_given? extensions = self.extensions.values operand.each { |operand_tuple| yield operand_tuple.extend(header, extensions) } self end |