Sha256: 9ba93fd81b00b84c08fe55a7b0b4fbd13c6404d09d4a7d852e12b99a7d049b89
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# encoding: utf-8 module Axiom module Algebra # The intersection between relations class Intersection < Relation include Relation::Operation::Set # Iterate over each tuple in the set # # @example # intersection = Intersection.new(left, right) # intersection.each { |tuple| ... } # # @yield [tuple] # # @yieldparam [Tuple] tuple # each tuple in the set # # @return [self] # # @api public def each return to_enum unless block_given? left.each { |tuple| yield tuple if right.include?(tuple) } self end # Insert a relation into the Intersection # # @example # new_relation = intersection.insert(other) # # @param [Relation] other # # @return [Intersection] # # @api public def insert(other) left.insert(other).intersect(right.insert(other)) end # Delete a relation from the Intersection # # @example # new_relation = intersection.delete(other) # # @param [Relation] other # # @return [Intersection] # # @api public def delete(other) left.delete(other).intersect(right.delete(other)) end module Methods extend Aliasable inheritable_alias(:& => :intersect) # Return the intersection between relations # # @example # intersection = relation.intersect(other) # # @param [Relation] other # # @return [Intersection] # # @api public def intersect(other) Intersection.new(self, other) end end # module Methods Relation.class_eval { include Methods } end # class Intersection end # module Algebra end # module Axiom
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
axiom-0.2.0 | lib/axiom/algebra/intersection.rb |
axiom-0.1.1 | lib/axiom/algebra/intersection.rb |
axiom-0.1.0 | lib/axiom/algebra/intersection.rb |