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

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.

Parameters:

  • arcs_in (Array<RDF::Statement>)
  • arcs_out (Array<RDF::Statement>)

Returns:

Raises:

  • (ShEx::NotMatched)

    with expression accessor to access matched and unmatched statements along with satisfied and unsatisfied operations.


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

#maximumInteger, Float::INFINITY

Maximum constraint (defaults to 1)

Returns:

  • (Integer, Float::INFINITY)

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

#minimumInteger

Minimum constraint (defaults to 1)

Returns:

  • (Integer)

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_constraintsArray<TripleConstraints>

Included TripleConstraints

Returns:

  • (Array<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

Returns:

  • (Boolean)

52
# File 'lib/shex/algebra/triple_expression.rb', line 52

def triple_expression?; true; end