Class: ShEx::Algebra::SemAct
- Defined in:
- lib/shex/algebra/semact.rb
Constant Summary collapse
- NAME =
:semact
Constants inherited from Operator
Instance Attribute Summary
Attributes inherited from Operator
#id, #logger, #operands, #options, #schema
Class Method Summary collapse
-
.from_shexj(operator, options = {}) ⇒ Operator
Creates an operator instance from a parsed ShExJ representation.
Instance Method Summary collapse
-
#enter(**options) ⇒ Boolean
Called on entry.
-
#exit(code: nil, matched: [], unmatched: [], depth: 0, **options) ⇒ void
Called on exit from containing TripleExpression.
-
#satisfies?(focus, matched: [], unmatched: [], depth: 0) ⇒ Boolean
The evaluation semActsSatisfied on a list of SemActs returns success or failure.
-
#semact? ⇒ Boolean
Does This operator is SemAct.
Methods inherited from Operator
#base_uri, #closed?, #each_descendant, #eql?, #expression, #expressions, #focus, #focus=, #initialize, #inspect, iri, #iri, #json_type, #matched, #matched=, #message, #message=, #not_matched, #not_satisfied, #operand, #parent, #parent=, #satisfied, #satisfied=, #satisfy, #semantic_actions, #serialize_value, #status, #structure_error, #to_h, #to_json, #to_sxp, #to_sxp_bin, #triple_expression?, #unmatched, #unmatched=, #unsatisfied, #unsatisfied=, #validate!, #value, value
Constructor Details
This class inherits a constructor from ShEx::Algebra::Operator
Class Method Details
.from_shexj(operator, options = {}) ⇒ Operator
Creates an operator instance from a parsed ShExJ representation
10 11 12 13 14 15 16 |
# File 'lib/shex/algebra/semact.rb', line 10 def self.from_shexj(operator, = {}) raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == "SemAct" raise ArgumentError, "missing name in #{operator.inspect}" unless operator.has_key?('name') code = operator.delete('code') operator['code'] = code if code # Reorders operands appropriately super end |
Instance Method Details
#enter(**options) ⇒ Boolean
Called on entry
28 29 30 31 32 |
# File 'lib/shex/algebra/semact.rb', line 28 def enter(**) if implementation = schema.extensions[operands.first.to_s] implementation.enter(code: operands[0], expression: parent, **) end end |
#exit(code: nil, matched: [], unmatched: [], depth: 0, **options) ⇒ void
This method returns an undefined value.
Called on exit from containing TripleExpression
75 76 77 78 79 80 81 82 83 |
# File 'lib/shex/algebra/semact.rb', line 75 def exit(code: nil, matched: [], unmatched: [], depth: 0, **) if implementation = schema.extensions[operands.first.to_s] implementation.exit(code: operands[1], matched: matched, unmatched: unmatched, expresssion: parent, depth: depth) end end |
#satisfies?(focus, matched: [], unmatched: [], depth: 0) ⇒ Boolean
The evaluation semActsSatisfied on a list of SemActs returns success or failure. The evaluation of an individual SemAct is implementation-dependent.
In addition to standard arguments ‘satsisfies` arguments, the current `matched` and `unmatched` statements may be passed. Additionally, all sub-classes of `Operator` have available `parent`, and `schema` accessors, which allows access to the operands of the parent, for example.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/shex/algebra/semact.rb', line 44 def satisfies?(focus, matched: [], unmatched: [], depth: 0) if implementation = schema.extensions[operands.first.to_s] if matched.empty? implementation.visit(code: operands[1], expression: parent, depth: depth) || not_satisfied("SemAct failed", unmatched: unmatched) end matched.all? do |statement| implementation.visit(code: operands[1], matched: statement, expression: parent, depth: depth) end || not_satisfied("SemAct failed", matched: matched, unmatched: unmatched) else status("unknown SemAct name #{operands.first}", depth: depth) {"expression: #{self.to_sxp}"} false end end |
#semact? ⇒ Boolean
Does This operator is SemAct
86 |
# File 'lib/shex/algebra/semact.rb', line 86 def semact?; true; end |