Class: ShEx::Algebra::NodeConstraint

Inherits:
Operator
  • Object
show all
Includes:
ShapeExpression
Defined in:
lib/shex/algebra/node_constraint.rb

Constant Summary collapse

NAME =
:nodeConstraint

Constants inherited from Operator

Operator::ARITY

Instance Attribute Summary

Attributes inherited from Operator

#id, #logger, #operands, #options, #schema

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ShapeExpression

#validate_expressions!, #validate_self_references!

Methods inherited from Operator

#base_uri, #closed?, #dup, #each_descendant, #eql?, #expression, #expressions, #find, #focus, #focus=, #initialize, #inspect, #iri, iri, #json_type, #matched, #matched=, #message, #message=, #not_matched, #not_satisfied, #operand, #parent, #parent=, #references, #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

Class Method Details

.from_shexj(operator, **options) ⇒ Operator

Creates an operator instance from a parsed ShExJ representation

Returns:

Raises:

  • (ArgumentError)


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

def self.from_shexj(operator, **options)
  raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'NodeConstraint'
  super
end

Instance Method Details

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

S is a NodeConstraint and satisfies2(focus, se) as described below in Node Constraints. Note that testing if a node satisfies a node constraint does not require a graph or shapeMap.

Parameters:

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

    for logging

  • options (Hash{Symbol => Object})

    Other, operand-specific options

Returns:

  • (Boolean)
  • (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.



22
23
24
25
26
27
28
29
30
# File 'lib/shex/algebra/node_constraint.rb', line 22

def satisfies?(focus, depth: 0)
  status "", depth: depth
  satisfies_node_kind?(focus, depth: depth + 1) &&
  satisfies_datatype?(focus, depth: depth + 1) &&
  satisfies_string_facet?(focus, depth: depth + 1) &&
  satisfies_numeric_facet?(focus, depth: depth + 1) &&
  satisfies_values?(focus, depth: depth + 1) &&
  satisfy(depth: depth)
end