Sha256: 81601be3dfe9e0ef743aa795be66d16bb3003602ac0d80c44488900e6fabc6ba

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

module ShEx::Algebra
  ##
  class And < Operator
    include Satisfiable
    NAME = :and

    def initialize(*args, **options)
      case
      when args.length <= 1
        raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 1..)"
      end
      super
    end

    #
    # S is a ShapeAnd and for every shape expression se2 in shapeExprs, satisfies(n, se2, G, m).
    # @param [RDF::Resource] n
    # @return [Boolean] `true` when satisfied
    # @raise [ShEx::NotSatisfied] if not satisfied
    def satisfies?(n)
      status ""

      # Operand raises NotSatisfied, so no need to check here.
      operands.select {|o| o.is_a?(Satisfiable)}.each {|op| op.satisfies?(n)}
      status("satisfied")
      true
    rescue ShEx::NotSatisfied => e
      not_satisfied(e.message)
      raise
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shex-0.1.0 lib/shex/algebra/and.rb