Sha256: 4a908f92314a3618149566205ec8e8aec802faaf226869244d2a377bf4ddbe3d

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 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

    ##
    # expressions must be ShapeExpressions or references to ShapeExpressions
    #
    # @return [Operator] `self`
    # @raise  [ShEx::StructureError] if the value is invalid
    def validate!
      validate_expressions!
      super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shex-0.8.0 lib/shex/algebra/start.rb
shex-0.7.1 lib/shex/algebra/start.rb
shex-0.7.0 lib/shex/algebra/start.rb
shex-0.6.4 lib/shex/algebra/start.rb