Class: ShEx::Algebra::And

Inherits:
Operator show all
Includes:
Satisfiable
Defined in:
lib/shex/algebra/and.rb

Constant Summary collapse

NAME =
:and

Constants inherited from Operator

Operator::ARITY

Instance Attribute Summary

Attributes inherited from Operator

#operands, #options, #schema

Instance Method Summary collapse

Methods included from Satisfiable

#not_satisfies?, #satisfiable?, #triple_expressions

Methods inherited from Operator

#closed?, #each_descendant, #eql?, #first_ancestor, #inspect, #not_matched, #not_satisfied, #operand, #parent, #parent=, #satisfiable?, #semact?, #semantic_actions, #status, #structure_error, #to_sxp, #to_sxp_bin, #triple_expression?, #validate!

Constructor Details

#initialize(*args, **options) ⇒ And

Returns a new instance of And.



7
8
9
10
11
12
13
# File 'lib/shex/algebra/and.rb', line 7

def initialize(*args, **options)
  case
  when args.length <= 1
    raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 1..)"
  end
  super
end

Instance Method Details

#satisfies?(n) ⇒ Boolean

S is a ShapeAnd and for every shape expression se2 in shapeExprs, satisfies(n, se2, G, m).

Parameters:

  • n (RDF::Resource)

Returns:

  • (Boolean)

    ‘true` when satisfied

Raises:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shex/algebra/and.rb', line 20

def satisfies?(n)
  status ""

  # Operand raises NotSatisfied, so no need to check here.
  operands.select {|o| o.is_a?(Satisfiable)}.each {|op| op.satisfies?(n)}
  status("satisfied")
  true
rescue ShEx::NotSatisfied => e
  not_satisfied(e.message)
  raise
end