Sha256: cd2d1bc56162c1f88d975a009a9d7090de988c735ed9e66a3d5225306e5d5696
Contents?: true
Size: 1.45 KB
Versions: 8
Compression:
Stored size: 1.45 KB
Contents
module ShEx::Algebra ## class Start < Operator::Unary include ShapeExpression NAME = :start # # @param (see ShapeExpression#satisfies?) # @return (see ShapeExpression#satisfies?) # @raise (see ShapeExpression#satisfies?) def satisfies?(focus, depth: 0) status "", depth: depth matched_op = case expression when RDF::Resource schema.enter_shape(expression, focus) do |shape| if shape shape.satisfies?(focus, depth: depth + 1) else status "Satisfy as #{expression} was re-entered for #{focus}", depth: depth nil end end when ShapeExpression expression.satisfies?(focus, depth: depth + 1) end satisfy focus: focus, satisfied: matched_op, depth: depth rescue ShEx::NotSatisfied => e not_satisfied e.message, focus: focus, unsatisfied: e.expression, depth: depth raise end ## # expression must be a ShapeExpression # # @return [Operator] `self` # @raise [ShEx::StructureError] if the value is invalid def validate! case expression when ShapeExpression when RDF::Resource ref = schema.find(expression) ref.is_a?(ShapeExpression) || structure_error("#{json_type} must reference a ShapeExpression: #{ref}") else structure_error("#{json_type} must reference a ShapeExpression: #{ref}") end super end end end
Version data entries
8 entries across 8 versions & 1 rubygems