Module: ShEx::Algebra::TripleExpression
- Included in:
- EachOf, OneOf, TripleConstraint
- Defined in:
- 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.
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 '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)
44 45 46 47 48 49 |
# File 'lib/shex/algebra/triple_expression.rb', line 44 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)
34 35 36 37 38 39 |
# File 'lib/shex/algebra/triple_expression.rb', line 34 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
22 23 24 25 26 27 28 29 |
# File 'lib/shex/algebra/triple_expression.rb', line 22 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
52 |
# File 'lib/shex/algebra/triple_expression.rb', line 52 def triple_expression?; true; end |