Class: ShEx::Algebra::Or
- Includes:
- Satisfiable
- Defined in:
- lib/shex/algebra/or.rb
Constant Summary collapse
- NAME =
:or
Constants inherited from Operator
ShEx::Algebra::Operator::ARITY
Instance Attribute Summary
Attributes inherited from Operator
Instance Method Summary collapse
-
#initialize(*args, **options) ⇒ Or
constructor
A new instance of Or.
-
#satisfies?(n) ⇒ Boolean
S is a ShapeOr and there is some shape expression se2 in shapeExprs such that satisfies(n, se2, G, m).
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) ⇒ Or
Returns a new instance of Or.
7 8 9 10 11 12 13 |
# File 'lib/shex/algebra/or.rb', line 7 def initialize(*args, **) 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 ShapeOr and there is some shape expression se2 in shapeExprs such that satisfies(n, se2, G, m).
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shex/algebra/or.rb', line 20 def satisfies?(n) any_not_satisfied = false operands.select {|o| o.is_a?(Satisfiable)}.any? do |op| begin op.satisfies?(n) status "satisfied #{n}" return true rescue ShEx::NotSatisfied => e log_recover("or: ignore error: #{e.message}", depth: .fetch(:depth, 0)) any_not_satisfied = e false end end not_satisfied "Expected some expression to be satisfied" end |