Module: ShEx::Algebra::TripleExpression
- Included in:
- EachOf, OneOf, TripleConstraint
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb
Overview
Implements neigh
, arcs_out
, args_in
and matches
Instance Method Summary collapse
-
#matches(arcs_in, arcs_out, depth: 0) ⇒ TripleExpression
matches
: asserts that a triple expression is matched by a set of triples that come from the neighbourhood of a node in an RDF graph. -
#maximum ⇒ Integer, Float::INFINITY
Maximum constraint (defaults to 1).
-
#minimum ⇒ Integer
Minimum constraint (defaults to 1).
-
#triple_constraints ⇒ Array<TripleConstraints>
Included TripleConstraints.
-
#triple_expression? ⇒ Boolean
This operator includes TripleExpression.
-
#validate_expressions! ⇒ Object
expressions must be TripleExpressions or references to TripleExpressions.
Instance Method Details
#matches(arcs_in, arcs_out, depth: 0) ⇒ TripleExpression
matches
: asserts that a triple expression is matched by a set of triples that come from the neighbourhood of a node in an RDF graph. The expression matches(T, expr, m)
indicates that a set of triples T
can satisfy these rules...
Behavior should be overridden in subclasses, which end by calling this through super
.
15 16 17 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb', line 15 def matches(arcs_in, arcs_out, depth: 0) raise NotImplementedError, "#matches Not implemented in #{self.class}" end |
#maximum ⇒ Integer, Float::INFINITY
Maximum constraint (defaults to 1)
62 63 64 65 66 67 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb', line 62 def maximum @maximum ||= begin op = operands.detect {|o| o.is_a?(Array) && o.first == :max} || [:max, 1] op[1] == '*' ? Float::INFINITY : op[1] end end |
#minimum ⇒ Integer
Minimum constraint (defaults to 1)
52 53 54 55 56 57 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb', line 52 def minimum @minimum ||= begin op = operands.detect {|o| o.is_a?(Array) && o.first == :min} || [:min, 1] op[1] end end |
#triple_constraints ⇒ Array<TripleConstraints>
Included TripleConstraints
40 41 42 43 44 45 46 47 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb', line 40 def triple_constraints @triple_contraints ||= operands.select do |o| o.is_a?(TripleExpression) end. map(&:triple_constraints). flatten. uniq end |
#triple_expression? ⇒ Boolean
This operator includes TripleExpression
70 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb', line 70 def triple_expression?; true; end |
#validate_expressions! ⇒ Object
expressions must be TripleExpressions or references to TripleExpressions
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/triple_expression.rb', line 23 def validate_expressions! expressions.each do |op| case op when TripleExpression when RDF::Resource ref = schema.find(op) ref.is_a?(TripleExpression) || structure_error("#{json_type} must reference a TripleExpression: #{ref}") else structure_error("#{json_type} must be a TripleExpression or reference: #{op.to_sxp}") end end end |