Module: ShEx::Algebra::ShapeExpression

Included in:
And, External, NodeConstraint, Not, Or, Shape, Start
Defined in:
lib/shex/algebra/shape_expression.rb

Overview

Implements satisfies? and not_satisfies?

Instance Method Summary collapse

Instance Method Details

#satisfies?(focus, depth: 0, **options) ⇒ ShapeExpression

Satisfies method

Parameters:

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

    for logging

  • options (Hash{Symbol => Object})

    Other, operand-specific options

Returns:

  • (ShapeExpression)

    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:



15
16
17
# File 'lib/shex/algebra/shape_expression.rb', line 15

def satisfies?(focus, depth: 0, **options)
  raise NotImplementedError, "#satisfies? Not implemented in #{self.class}"
end

#validate_expressions!Object

expressions must be ShapeExpressions or references.

Raises:



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

def validate_expressions!
  expressions.each do |op|
    case op
    when ShapeExpression
    when RDF::Resource
      ref = schema.find(op)
      ref.is_a?(ShapeExpression) ||
      structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
    else
      structure_error("#{json_type} must be a ShapeExpression or reference: #{op.to_sxp}")
    end
  end
end

#validate_self_references!Object

An Operator with a label must contain a reference to itself.

Raises:



41
42
43
44
45
46
# File 'lib/shex/algebra/shape_expression.rb', line 41

def validate_self_references!
  return # FIXME: needs to stop at a TripleConstraint
  each_descendant do |op|
    structure_error("#{json_type} must not reference itself (#{id}): #{op.to_sxp}") if op.references.include?(id)
  end
end