Sha256: 035fd234c296ca2054b39f13b094c924fb40975b9d35e282f4d8b9b7d90fb87e

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

module ShEx::Algebra
  ##
  class Value < Operator::Unary
    NAME = :value

    ##
    # For a node n and constraint value v, nodeSatisfies(n, v) if n matches some valueSetValue vsv in v. A term matches a valueSetValue if:
    #
    # * vsv is an objectValue and n = vsv.
    # * vsv is a Stem with stem st and nodeIn(n, st).
    # * vsv is a StemRange with stem st and exclusions excls and nodeIn(n, st) and there is no x in excls such that nodeIn(n, excl).
    # * vsv is a Wildcard with exclusions excls and there is no x in excls such that nodeIn(n, excl).
    def match?(value, depth: 0)
      status "", depth: depth
      if case expr = operands.first
        when RDF::Value then value.eql?(expr)
        when Stem, StemRange then expr.match?(value, depth: depth + 1)
        else false
        end
        status "matched #{value}", depth: depth
        true
      else
        status "not matched #{value}", depth: depth
        false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shex-0.5.0 lib/shex/algebra/value.rb
shex-0.4.0 lib/shex/algebra/value.rb
shex-0.3.0 lib/shex/algebra/value.rb