Sha256: 7c8620d339e73ffce8d3ceadff7374149cd9cd5b9af3715e50ef8479dc4d189d

Contents?: true

Size: 1.33 KB

Versions: 32

Compression:

Stored size: 1.33 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_accessor :type
      protected :type=

      def each(&bl)
      end

      def _count
        0
      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

32 entries across 32 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/relation/empty.rb
bmg-0.23.2 lib/bmg/relation/empty.rb
bmg-0.23.1 lib/bmg/relation/empty.rb
bmg-0.23.0 lib/bmg/relation/empty.rb
bmg-0.21.5 lib/bmg/relation/empty.rb
bmg-0.21.4 lib/bmg/relation/empty.rb
bmg-0.20.5 lib/bmg/relation/empty.rb
bmg-0.19.3 lib/bmg/relation/empty.rb
bmg-0.21.3 lib/bmg/relation/empty.rb
bmg-0.21.2 lib/bmg/relation/empty.rb
bmg-0.21.0 lib/bmg/relation/empty.rb
bmg-0.20.4 lib/bmg/relation/empty.rb
bmg-0.20.2 lib/bmg/relation/empty.rb
bmg-0.20.1 lib/bmg/relation/empty.rb
bmg-0.20.0 lib/bmg/relation/empty.rb
bmg-0.19.2 lib/bmg/relation/empty.rb
bmg-0.19.1 lib/bmg/relation/empty.rb
bmg-0.19.0 lib/bmg/relation/empty.rb
bmg-0.18.15 lib/bmg/relation/empty.rb
bmg-0.18.14 lib/bmg/relation/empty.rb