Sha256: 7448e47ed7c7fa96caebac7d4a4731e8c7e76bb81205d9901d7a447b2333d8dd

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

module Veritas
  class Relation

    # A materialized relation
    class Materialized < Relation

      # Initialize a materialized Relation
      #
      # @param [Header, #to_ary] header
      #   the relation header
      # @param [Enumerable] tuples
      #   the relation tuples
      # @param [Operation::Order::DirectionSet] directions
      #   optional directions to sort the relation by
      #
      # @return [undefined]
      #
      # @api private
      def initialize(header, tuples, directions = Operation::Order::DirectionSet::EMPTY)
        super(header, tuples)
        @directions = Operation::Order::DirectionSet.coerce(directions)
      end

      # A noop for Materialized relations
      #
      # @example
      #   materialized.materialize  # (Always returns self)
      #
      # @return [self]
      #
      # @api public
      def materialize
        self
      end

      # Test if there are no tuples
      #
      # @example
      #   materialized.empty?  # => true or false
      #
      # @return [Boolean]
      #
      # @api public
      def empty?
        tuples.empty?
      end

      # Return the number of tuples
      #
      # @example
      #   materialized.size  # => 10
      #
      # @return [Integer]
      #
      # @api public
      def size
        tuples.size
      end

    end # class Materialized
  end # class Relation
end # module Veritas

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritas-0.0.3 lib/veritas/relation/materialized.rb
veritas-0.0.2 lib/veritas/relation/materialized.rb
veritas-0.0.1 lib/veritas/relation/materialized.rb