Module: ShEx::Algebra::TripleExpression

Included in:
EachOf, Inclusion, 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(t) ⇒ Array<RDF::Statement>

‘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:

  • t (Array<RDF::Statement>)

Returns:

  • (Array<RDF::Statement>)

Raises:

  • NotMatched, ShEx::NotSatisfied



16
17
18
# File 'lib/shex/algebra/triple_expression.rb', line 16

def matches(t)
  raise NotImplementedError, "#matches Not implemented in #{self.class}"
end

#maximumInteger, Float::INFINITY

Maximum constraint (defaults to 1)

Returns:

  • (Integer, Float::INFINITY)


38
39
40
41
# File 'lib/shex/algebra/triple_expression.rb', line 38

def maximum
  op = operands.detect {|o| o.is_a?(Array) && o.first == :max} || [:max, 1]
  op[1] == '*' ? Float::INFINITY : op[1]
end

#minimumInteger

Minimum constraint (defaults to 1)

Returns:

  • (Integer)


30
31
32
33
# File 'lib/shex/algebra/triple_expression.rb', line 30

def minimum
  op = operands.detect {|o| o.is_a?(Array) && o.first == :min} || [:min, 1]
  op[1]
end

#triple_constraintsArray<TripleConstraints>

Included TripleConstraints

Returns:

  • (Array<TripleConstraints>)


23
24
25
# File 'lib/shex/algebra/triple_expression.rb', line 23

def triple_constraints
  operands.select {|o| o.is_a?(TripleExpression)}.map(&:triple_constraints).flatten.uniq
end

#triple_expression?Boolean

This operator includes TripleExpression

Returns:

  • (Boolean)


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

def triple_expression?; true; end