Sha256: ae924794941b6495c6541737d60058b6e0d81a390d2f4c1fb66d191ebb4d50c6

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module SHACL::Algebra
  ##
  class Not < Operator
    NAME = :not

    ##
    # Specifies the condition that each value node cannot conform to a given shape. This is comparable to negation and the logical "not" operator.
    #
    # @param [RDF::Term] node
    # @param [Hash{Symbol => Object}] options
    # @return [Array<SHACL::ValidationResult>]
    def conforms(node, path: nil, depth: 0, **options)
      log_debug(NAME, depth: depth) {SXP::Generator.string({node: node}.to_sxp_bin)}
      operands.each do |op|
        results = op.conforms(node, depth: depth + 1, **options)
        if results.any?(&:conform?)
          return not_satisfied(focus: node, path: path,
            message: "node does not conform to some shape",
            resultSeverity: options.fetch(:severity),
            component: RDF::Vocab::SHACL.NotConstraintComponent,
            value: node, depth: depth, **options)
        end
      end
      satisfy(focus: node, path: path,
        message: "node conforms to all shapes",
        component: RDF::Vocab::SHACL.NotConstraintComponent,
        value: node, depth: depth, **options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shacl-0.2.1 lib/shacl/algebra/not.rb
shacl-0.2.0 lib/shacl/algebra/not.rb
shacl-0.1.1 lib/shacl/algebra/not.rb
shacl-0.1.0 lib/shacl/algebra/not.rb