Module: ShEx::Algebra

Defined in:
lib/shex/algebra.rb,
lib/shex/algebra/or.rb,
lib/shex/algebra/and.rb,
lib/shex/algebra/not.rb,
lib/shex/algebra/stem.rb,
lib/shex/algebra/shape.rb,
lib/shex/algebra/start.rb,
lib/shex/algebra/value.rb,
lib/shex/algebra/import.rb,
lib/shex/algebra/one_of.rb,
lib/shex/algebra/schema.rb,
lib/shex/algebra/semact.rb,
lib/shex/algebra/each_of.rb,
lib/shex/algebra/external.rb,
lib/shex/algebra/language.rb,
lib/shex/algebra/operator.rb,
lib/shex/algebra/annotation.rb,
lib/shex/algebra/stem_range.rb,
lib/shex/algebra/node_constraint.rb,
lib/shex/algebra/shape_expression.rb,
lib/shex/algebra/triple_constraint.rb,
lib/shex/algebra/triple_expression.rb

Overview

Based on the SPARQL Algebra, operators for executing a patch

Author:

Defined Under Namespace

Modules: ReferencedStatement, ShapeExpression, TripleExpression Classes: And, Annotation, EachOf, External, Import, IriStem, IriStemRange, Language, LanguageStem, LanguageStemRange, LiteralStem, LiteralStemRange, NodeConstraint, Not, OneOf, Operator, Or, Schema, SemAct, Shape, ShapeResult, Start, Stem, StemRange, TripleConstraint, Value

Class Method Summary collapse

Class Method Details

.from_shexj(operator, **options) ⇒ Operator

Creates an operator instance from a parsed ShExJ representation

Examples:

Simple TripleConstraint

rep = JSON.parse(%({
        "type": "TripleConstraint",
        "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
      }
))
TripleConstraint.from(rep) #=> (tripleConstraint a)

Parameters:

  • operator (Hash)
  • options (Hash)

    ({})

Options Hash (**options):

  • :base (RDF::URI)
  • :prefixes (Hash{String => RDF::URI})

Returns:

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/shex/algebra.rb', line 52

def self.from_shexj(operator, **options)
  raise ArgumentError unless operator.is_a?(Hash)
  klass = case operator['type']
  when 'Annotation'         then Annotation
  when 'EachOf'             then EachOf
  when 'IriStem'            then IriStem
  when 'IriStemRange'       then IriStemRange
  when 'Language'           then Language
  when 'LanguageStem'       then LanguageStem
  when 'LanguageStemRange'  then LanguageStemRange
  when 'LiteralStem'        then LiteralStem
  when 'LiteralStemRange'   then LiteralStemRange
  when 'NodeConstraint'     then NodeConstraint
  when 'OneOf'              then OneOf
  when 'Schema'             then Schema
  when 'SemAct'             then SemAct
  when 'Shape'              then Shape
  when 'ShapeAnd'           then And
  when 'ShapeExternal'      then External
  when 'ShapeNot'           then Not
  when 'ShapeOr'            then Or
  when 'TripleConstraint'   then TripleConstraint
  when 'Wildcard'           then StemRange
  else raise ArgumentError, "unknown type #{operator['type'].inspect}"
  end

  klass.from_shexj(operator, **options)
end