Sha256: d9cf4e4975f32faed080b3715fd92b0c16e4bcb7479e4766e21274f9f516cc7d

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module Bmg
  module Relation
    #
    # The empty relation, of a given type.
    #
    # This relation implementation exists mostly for optimization
    # purposes, since knowing that a relation is empty allows
    # simplifying many expressions.
    #
    class Empty
      include Relation

      def initialize(type)
        @type = type
      end
      attr_reader :type

      def each(&bl)
      end

      def to_ast
        [ :empty ]
      end

      def to_s
        "(empty)"
      end

      def inspect
        "(empty)"
      end

    protected ### optimization

      def _allbut(type, *args)
        Empty.new(type)
      end

      def _autosummarize(type, *args)
        Empty.new(type)
      end

      def _autowrap(type, *args)
        Empty.new(type)
      end

      def _constants(type, cs)
        Empty.new(type)
      end

      def _extend(type, *args)
        Empty.new(type)
      end

      def _image(type, *args)
        Empty.new(type)
      end

      def _project(type, *args)
        Empty.new(type)
      end

      def _rename(type, *args)
        Empty.new(type)
      end

      def _restrict(type, predicate)
        self
      end

      def _union(type, other, options)
        other
      end

    end # class Empty
  end # module Relation
end # module Bmg

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bmg-0.13.0 lib/bmg/relation/empty.rb