Class: ShEx::Algebra::ShapeRef
- Inherits:
-
Operator::Unary
- Object
- Operator
- Operator::Unary
- ShEx::Algebra::ShapeRef
- Includes:
- Satisfiable
- Defined in:
- lib/shex/algebra/shape_ref.rb
Constant Summary collapse
- NAME =
:shapeRef
Constants inherited from Operator::Unary
Constants inherited from Operator
Instance Attribute Summary
Attributes inherited from Operator
Instance Method Summary collapse
-
#initialize(arg, **options) ⇒ ShapeRef
constructor
A new instance of ShapeRef.
-
#referenced_shape ⇒ Shape
Returns the referenced shape.
-
#satisfies?(n) ⇒ Boolean
Satisfies method.
-
#validate! ⇒ Object
A ShapeRef is valid if it’s ancestor schema has any shape with a lable the same as it’s reference.
Methods included from Satisfiable
#not_satisfies?, #satisfiable?, #triple_expressions
Methods inherited from Operator
#closed?, #each_descendant, #eql?, #first_ancestor, #inspect, #not_matched, #not_satisfied, #operand, #parent, #parent=, #satisfiable?, #semact?, #semantic_actions, #status, #structure_error, #to_sxp, #to_sxp_bin, #triple_expression?
Constructor Details
#initialize(arg, **options) ⇒ ShapeRef
Returns a new instance of ShapeRef.
7 8 9 10 |
# File 'lib/shex/algebra/shape_ref.rb', line 7 def initialize(arg, **) structure_error("Shape reference must be an IRI or BNode: #{arg}", exception: ArgumentError) unless arg.is_a?(RDF::Resource) super end |
Instance Method Details
#referenced_shape ⇒ Shape
Returns the referenced shape
32 33 34 |
# File 'lib/shex/algebra/shape_ref.rb', line 32 def referenced_shape schema.shapes[operands.first.to_s] end |
#satisfies?(n) ⇒ Boolean
Satisfies method
18 19 20 21 22 23 24 25 26 |
# File 'lib/shex/algebra/shape_ref.rb', line 18 def satisfies?(n) status "ref #{operands.first.to_s}" referenced_shape.satisfies?(n) status "ref satisfied" true rescue ShEx::NotSatisfied => e not_satisfied e. raise end |
#validate! ⇒ Object
A ShapeRef is valid if it’s ancestor schema has any shape with a lable the same as it’s reference.
39 40 41 42 43 44 |
# File 'lib/shex/algebra/shape_ref.rb', line 39 def validate! structure_error("Missing referenced shape: #{operands.first}") if referenced_shape.nil? # FIXME #raise ShEx::ParseError, "Self referencing shape: #{operands.first}" if referenced_shape == first_ancestor(Shape) super end |