Class: ShEx::Algebra::Not

Inherits:
Operator::Unary show all
Includes:
Satisfiable
Defined in:
lib/shex/algebra/not.rb

Constant Summary collapse

NAME =
:not

Constants inherited from Operator::Unary

Operator::Unary::ARITY

Constants inherited from Operator

Operator::ARITY

Instance Attribute Summary

Attributes inherited from Operator

#label, #logger, #operands, #options, #schema

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Satisfiable

#satisfiable?

Methods inherited from Operator::Unary

#initialize

Methods inherited from Operator

#base_uri, #closed?, #each_descendant, #eql?, #first_ancestor, #focus, #focus=, #initialize, #inspect, #iri, iri, #matched, #matched=, #message, #message=, #not_matched, #not_satisfied, #operand, #parent, #parent=, #satisfiable?, #satisfied, #satisfied=, #satisfy, #semact?, #semantic_actions, #serialize_value, #status, #structure_error, #to_h, #to_json, #to_sxp, #to_sxp_bin, #triple_expression?, #unmatched, #unmatched=, #unsatisfied, #unsatisfied=, #validate!, #value, value

Constructor Details

This class inherits a constructor from ShEx::Algebra::Operator::Unary

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShEx::Algebra::Operator

Class Method Details

.from_shexj(operator, options = {}) ⇒ Operator

Creates an operator instance from a parsed ShExJ representation

Returns:

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/shex/algebra/not.rb', line 11

def self.from_shexj(operator, options = {})
  raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'ShapeNot'
  raise ArgumentError, "missing shapeExpr in #{operator.inspect}" unless operator.has_key?('shapeExpr')
  super
end

Instance Method Details

#json_typeObject



34
35
36
# File 'lib/shex/algebra/not.rb', line 34

def json_type
  "ShapeNot"
end

#satisfies?(focus, depth: 0) ⇒ Boolean, Operator

S is a ShapeNot and for the shape expression se2 at shapeExpr, notSatisfies(n, se2, G, m).

Parameters:

  • focus (RDF::Resource)
  • depth (Integer) (defaults to: 0)

    for logging

  • options (Hash{Symbol => Object})

    Other, operand-specific options

Returns:

  • (Boolean)
  • (Operator)

    with ‘matched` and `satisfied` accessors for matched triples and sub-expressions

Raises:

  • (ShEx::NotMatched)

    with ‘expression` accessor to access `matched` and `unmatched` statements along with `satisfied` and `unsatisfied` operations.

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/shex/algebra/not.rb', line 23

def satisfies?(focus, depth: 0)
  status ""
  satisfied_op = begin
    operands.last.satisfies?(focus, depth: depth + 1)
  rescue ShEx::NotSatisfied => e
    return satisfy focus: focus, satisfied: e.expression.unsatisfied, depth: depth
  end
  not_satisfied "Expression should not have matched",
    focus: focus, unsatisfied: satisfied_op, depth: depth
end