Sha256: a6d604a7614a044de32c8b267137eb61409e51559afdd61714aed84de0d512d1

Contents?: true

Size: 965 Bytes

Versions: 8

Compression:

Stored size: 965 Bytes

Contents

module Alf
  module Algebra
    #
    # Specialization of Operator for operators that work on a binary input
    #
    module Binary

      # Class-level methods
      module ClassMethods

        # (see Operator::ClassMethods#arity)
        def arity
          2
        end

      end # module ClassMethods

      def self.included(mod)
        super
        mod.extend(ClassMethods)
      end

      # Returns the left operand
      def left
        operands.first
      end

      # Returns the right operand
      def right
        operands.last
      end

      def with_left(left)
        with_operands(left, right)
      end

      def with_right(right)
        with_operands(left, right)
      end

      def common_heading
        @common_heading ||= (left.heading & right.heading)
      end

      def common_attributes
        @common_attributes ||= common_heading.to_attr_list
      end

    end # module Binary
  end # module Algebra
end # module Alf

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/algebra/support/binary.rb
alf-core-0.16.2 lib/alf/algebra/support/binary.rb
alf-core-0.16.1 lib/alf/algebra/support/binary.rb
alf-core-0.16.0 lib/alf/algebra/support/binary.rb
alf-core-0.15.0 lib/alf/algebra/support/binary.rb
alf-core-0.14.0 lib/alf-algebra/alf/algebra/support/binary.rb
alf-core-0.13.1 lib/alf-algebra/alf/algebra/support/binary.rb
alf-core-0.13.0 lib/alf-algebra/alf/algebra/support/binary.rb