Sha256: 8d624078980ee486609726dd175d09d40760609f0e26e116e8b0adca2c44894c

Contents?: true

Size: 984 Bytes

Versions: 10

Compression:

Stored size: 984 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 Language, 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

10 entries across 10 versions & 1 rubygems

Version Path
shex-0.8.0 lib/shex/algebra/value.rb
shex-0.7.1 lib/shex/algebra/value.rb
shex-0.7.0 lib/shex/algebra/value.rb
shex-0.6.4 lib/shex/algebra/value.rb
shex-0.6.3 lib/shex/algebra/value.rb
shex-0.6.2 lib/shex/algebra/value.rb
shex-0.6.1 lib/shex/algebra/value.rb
shex-0.6.0 lib/shex/algebra/value.rb
shex-0.5.2 lib/shex/algebra/value.rb
shex-0.5.1 lib/shex/algebra/value.rb