Class: ShEx::Algebra::SemAct

Inherits:
Operator show all
Defined in:
lib/shex/algebra/semact.rb

Constant Summary collapse

NAME =
:semact

Constants inherited from Operator

Operator::ARITY

Instance Attribute Summary

Attributes inherited from Operator

#operands, #options, #schema

Instance Method Summary collapse

Methods inherited from Operator

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

Constructor Details

This class inherits a constructor from ShEx::Algebra::Operator

Instance Method Details

#satisfies?(statements) ⇒ Boolean

The evaluation semActsSatisfied on a list of SemActs returns success or failure. The evaluation of an individual SemAct is implementation-dependent.

Parameters:

  • statements (Array<RDF::Statement>)

Returns:

  • (Boolean)

    ‘true` if satisfied, `false` if it does not apply

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/shex/algebra/semact.rb', line 11

def satisfies?(statements)
  # FIXME: should have a registry
  case operands.first.to_s
  when "http://shex.io/extensions/Test/"
    str = if md = /^ *(fail|print) *\( *(?:(\"(?:[^\\"]|\\")*\")|([spo])) *\) *$/.match(operands[1].to_s)
      md[2] || case md[3]
      when 's' then statements.first.subject
      when 'p' then statements.first.predicate
      when 'o' then statements.first.object
      else          statements.first.to_sxp
      end.to_s
    else
      statements.empty? ? 'no statement' : statements.first.to_sxp
    end
    $stdout.puts str
    status str
    not_satisfied "fail" if md && md[1] == 'fail'
    true
  else
    status("unknown SemAct name #{operands.first}") {"expression: #{self.to_sxp}"}
    false
  end
end

#semact?Boolean

Does This operator is SemAct

Returns:

  • (Boolean)


36
# File 'lib/shex/algebra/semact.rb', line 36

def semact?; true; end