Sha256: 40bacf4734ebd0e57b384374f440e9ffba08436a7790b94861ff835b03436cb6

Contents?: true

Size: 870 Bytes

Versions: 5

Compression:

Stored size: 870 Bytes

Contents

module Alf
  module Algebra
    class Clip
      include Operator
      include NonRelational
      include Unary

      signature do |s|
        s.argument :attributes, AttrList, []
        s.option   :allbut,     Boolean, false, "Apply an allbut clipping?"
      end

      def heading
        @heading ||= operand.heading.project(attributes, allbut)
      end

      def keys
        @keys ||= operand.keys.select{|k|
          k.project(attributes, allbut) == k
        }.if_empty{ Keys[ heading.to_attr_list ] }
      end

      def key_preserving?
        keys.any?{|k| operand.keys.include?(k) }
      end

      def stay_attributes
        allbut ? heading.to_attr_list : attributes
      end

    private

      def _type_check(options)
        no_unknown!(attributes - operand.attr_list)
      end

    end # class Clip
  end # module Algebra
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/algebra/operator/clip.rb
alf-core-0.16.2 lib/alf/algebra/operator/clip.rb
alf-core-0.16.1 lib/alf/algebra/operator/clip.rb
alf-core-0.16.0 lib/alf/algebra/operator/clip.rb
alf-core-0.15.0 lib/alf/algebra/operator/clip.rb