Sha256: 1dcce7a2ad84f9444f5118e01dd2d52425fb3048287eb2c90d504bcb40cfce52

Contents?: true

Size: 888 Bytes

Versions: 5

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

module Fear
  module PartialFunction
    class Guard
      # @api private
      class Or < Guard
        # @param c1 [Fear::PartialFunction::Guard]
        # @param c2 [Fear::PartialFunction::Guard]
        def initialize(c1, c2)
          @c1 = c1
          @c2 = c2
        end
        attr_reader :c1, :c2
        private :c1
        private :c2

        # @param other [Fear::PartialFunction::Guard]
        # @return [Fear::PartialFunction::Guard]
        def and(other)
          Guard::And.new(self, other)
        end

        # @param other [Fear::PartialFunction::Guard]
        # @return [Fear::PartialFunction::Guard]
        def or(other)
          Guard::Or.new(self, other)
        end

        # @param arg [any]
        # @return [Boolean]
        def ===(arg)
          (c1 === arg) || (c2 === arg)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fear-3.0.0 lib/fear/partial_function/guard/or.rb
fear-2.0.1 lib/fear/partial_function/guard/or.rb
fear-2.0.0 lib/fear/partial_function/guard/or.rb
fear-1.2.0 lib/fear/partial_function/guard/or.rb
fear-1.1.0 lib/fear/partial_function/guard/or.rb