Class: ShEx::Test
- Inherits:
-
Object
- Object
- ShEx::Test
- Defined in:
- lib/shex/extensions/test.rb
Instance Method Summary collapse
-
#visit(code: nil, matched: nil, depth: 0, **options) ⇒ Boolean
Called after a TripleExpression has matched zero or more statements.
Instance Method Details
#visit(code: nil, matched: nil, depth: 0, **options) ⇒ Boolean
Called after a ShEx::TripleExpression has matched zero or more statements
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/shex/extensions/test.rb', line 11 def visit(code: nil, matched: nil, depth: 0, **) str = if md = /^ *(fail|print) *\( *(?:(\"(?:[^\\"]|\\")*\")|([spo])) *\) *$/.match(code.to_s) md[2] || case md[3] when 's' then matched.subject when 'p' then matched.predicate when 'o' then matched.object else matched.to_sxp end.to_s else matched ? matched.to_sxp : 'no statement' end $stdout.puts str return !md || md[1] == 'print' end |