Class: ShEx::Algebra::LanguageStemRange
- Inherits:
- 
      StemRange
      
        - Object
- Operator
- Operator::Binary
- StemRange
- ShEx::Algebra::LanguageStemRange
 
- Defined in:
- lib/shex/algebra/stem_range.rb
Constant Summary collapse
- NAME =
- :languageStemRange
Constants inherited from Operator::Binary
Constants inherited from Operator
Instance Attribute Summary
Attributes inherited from Operator
#id, #logger, #operands, #options, #schema
Instance Method Summary collapse
- 
  
    
      #match?(value, depth: 0)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    For a node n and constraint value v, nodeSatisfies(n, v) if n matches some valueSetValue vsv in v. 
Methods inherited from StemRange
Methods inherited from Operator::Binary
Methods inherited from Operator
#base_uri, #closed?, #dup, #each_descendant, #eql?, #expression, #expressions, #find, #focus, #focus=, from_shexj, #initialize, #inspect, #iri, iri, #json_type, #matched, #matched=, #message, #message=, #not_matched, #not_satisfied, #operand, #parent, #parent=, #references, #satisfied, #satisfied=, #satisfy, #semact?, #semantic_actions, #serialize_value, #status, #structure_error, #to_h, #to_json, #to_sxp, #to_sxp_bin, #triple_expression?, #unmatched, #unmatched=, #unsatisfied, #unsatisfied=, #validate!, #value, value
Constructor Details
This class inherits a constructor from ShEx::Algebra::Operator::Binary
Instance Method Details
#match?(value, depth: 0) ⇒ Boolean
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 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). 
| 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | # File 'lib/shex/algebra/stem_range.rb', line 102 def match?(value, depth: 0) initial_match = case operands.first when :wildcard then true when RDF::Literal value.language? && (operands.first.to_s.empty? || value.language.to_s.match?(%r(^#{operands.first}((-.*)?)$))) else false end unless initial_match status "#{value} does not match #{operands.first}", depth: depth return false end if exclusions.any? do |exclusion| case exclusion when RDF::Literal, String then value.language.to_s == exclusion when Stem then exclusion.match?(value, depth: depth + 1) else false end end status "#{value} excluded", depth: depth return false end status "matched #{value}", depth: depth true end |