Class: ShEx::Algebra::Operator Abstract
- Inherits:
-
Object
- Object
- ShEx::Algebra::Operator
- Extended by:
- SPARQL::Algebra::Expression
- Includes:
- RDF::Util::Logger
- Defined in:
- lib/shex/algebra/operator.rb
Overview
The ShEx operator.
Direct Known Subclasses
And, Annotation, EachOf, External, Inclusion, NodeConstraint, OneOf, Binary, Unary, Or, Schema, SemAct, Shape, TripleConstraint
Defined Under Namespace
Constant Summary collapse
- ARITY =
variable arity
-1 # variable arity
Instance Attribute Summary collapse
-
#label ⇒ RDF::Resource
The label (or subject) of this operand.
-
#logger ⇒ Logger
writeonly
Logging support (reader is in RDF::Util::Logger).
-
#operands ⇒ Array
readonly
The operands to this operator.
-
#options ⇒ Object
Initialization options.
-
#schema ⇒ Object
Location of schema including this operator.
Class Method Summary collapse
-
.from_shexj(operator, options = {}) ⇒ Operator
Creates an operator instance from a parsed ShExJ representation.
-
.iri(value, options) ⇒ RDF::Value
Create URIs.
-
.value(value, options) ⇒ RDF::Value
Create Values, with “clever” matching to see if it might be a value, IRI or BNode.
Instance Method Summary collapse
-
#base_uri ⇒ HRDF::URI
Returns the Base URI defined for the parser, as specified or when parsing a BASE prologue element.
-
#closed? ⇒ Boolean
Is this shape closed?.
-
#each_descendant(depth = 0) {|operator| ... } ⇒ Enumerator
(also: #descendants, #each)
Enumerate via depth-first recursive descent over operands, yielding each operator.
- #eql?(other) ⇒ Boolean (also: #==)
-
#first_ancestor(klass) ⇒ Operator
First ancestor operator of type ‘klass`.
-
#focus ⇒ Object
On a result instance, the focus of the expression.
- #focus=(node) ⇒ Object
-
#initialize(*operands) ⇒ Operator
constructor
Initializes a new operator instance.
-
#inspect ⇒ String
Returns a developer-friendly representation of this operator.
-
#iri(value, options = @options) ⇒ RDF::Value
Create URIs.
- #json_type ⇒ Object
-
#matched ⇒ Array<Statement>
On a result instance, the statements that matched this expression.
- #matched=(statements) ⇒ Object
-
#message ⇒ String
On a result instance, the failure message.
- #message=(str) ⇒ Object
-
#not_matched(message, **opts, &block) ⇒ Object
Exception handling.
- #not_satisfied(message, **opts) ⇒ Object
-
#operand(index = 0) ⇒ RDF::Term
Returns the operand at the given ‘index`.
-
#parent ⇒ Operator
Parent expression, if any.
-
#parent=(operator) ⇒ Operator
Parent operator, if any.
-
#satisfiable? ⇒ Boolean
Does this operator include Satisfiable?.
-
#satisfied ⇒ Array<Operator>
On a result instance, the sub-expressions which were matched.
- #satisfied=(ops) ⇒ Object
-
#satisfy(focus: nil, matched: nil, unmatched: nil, satisfied: nil, unsatisfied: nil, message: nil, **opts) ⇒ Operand
Duplication this operand, and add ‘matched`, `unmatched`, `satisfied`, and `unsatisfied` operands for accessing downstream.
-
#semact? ⇒ Boolean
Does this operator a SemAct?.
-
#semantic_actions ⇒ Array<SemAct>
Semantic Actions.
-
#serialize_value(value) ⇒ String
Serialize a value, either as JSON, or as modififed N-Triples.
- #status(message, **opts, &block) ⇒ Object
- #structure_error(message, **opts) ⇒ Object
-
#to_h ⇒ Hash
Create a hash version of the operator, suitable for turning into JSON.
- #to_json(options = nil) ⇒ Object
-
#to_sxp ⇒ String
Returns an S-Expression (SXP) representation of this operator.
-
#to_sxp_bin ⇒ Array
Returns the binary S-Expression (SXP) representation of this operator.
-
#triple_expression? ⇒ Boolean
Does this operator include TripleExpression?.
-
#unmatched ⇒ Array<Statement>
On a result instance, the statements that did not match this expression (failure only).
- #unmatched=(statements) ⇒ Object
-
#unsatisfied ⇒ Array<Operator>
On a result instance, the sub-satisfieables which were not satisfied.
- #unsatisfied=(ops) ⇒ Object
-
#validate! ⇒ SPARQL::Algebra::Expression
Validate all operands, operator specific classes should override for operator-specific validation.
-
#value(value, options = @options) ⇒ RDF::Value
Create Values, with “clever” matching to see if it might be a value, IRI or BNode.
Constructor Details
#initialize(*operands) ⇒ Operator #initialize(*operands, options) ⇒ Operator
Initializes a new operator instance.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/shex/algebra/operator.rb', line 38 def initialize(*operands) @options = operands.last.is_a?(Hash) ? operands.pop.dup : {} @operands = operands.map! do |operand| case operand when Array operand.each do |op| op.parent = self if op.respond_to?(:parent=) end operand when Operator, RDF::Term, RDF::Query, RDF::Query::Pattern, Array, Symbol operand.parent = self if operand.respond_to?(:parent=) operand when TrueClass, FalseClass, Numeric, String, DateTime, Date, Time RDF::Literal(operand) when NilClass raise ArgumentError, "Found nil operand for #{self.class.name}" else raise TypeError, "invalid ShEx::Algebra::Operator operand: #{operand.inspect}" end end @label = [:label] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (protected)
Implement ‘to_hash` only if accessed; otherwise, it becomes an _Implicit Accessor_ which will cause problems with splat arguments, which causes the last to be turned into a hash for extracting keyword aruments.
610 611 612 613 |
# File 'lib/shex/algebra/operator.rb', line 610 def method_missing(method, *args) return to_h(*args) if method == :hash super end |
Instance Attribute Details
#label ⇒ RDF::Resource
The label (or subject) of this operand
201 202 203 |
# File 'lib/shex/algebra/operator.rb', line 201 def label @label end |
#logger=(value) ⇒ Logger (writeonly)
Logging support (reader is in RDF::Util::Logger)
206 207 208 |
# File 'lib/shex/algebra/operator.rb', line 206 def logger=(value) @logger = value end |
#operands ⇒ Array (readonly)
The operands to this operator.
196 197 198 |
# File 'lib/shex/algebra/operator.rb', line 196 def operands @operands end |
#options ⇒ Object
Initialization options
19 20 21 |
# File 'lib/shex/algebra/operator.rb', line 19 def @options end |
#schema ⇒ Object
Location of schema including this operator
16 17 18 |
# File 'lib/shex/algebra/operator.rb', line 16 def schema @schema end |
Class Method Details
.from_shexj(operator, options = {}) ⇒ Operator
Creates an operator instance from a parsed ShExJ representation
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/shex/algebra/operator.rb', line 251 def self.from_shexj(operator, = {}) [:context] ||= JSON::LD::Context.parse(ShEx::CONTEXT) operands = [] label = nil operator.each do |k, v| case k when /length|pattern|clusive/ then operands << [k.to_sym, v] when 'label' then label = iri(v, ) when 'min', 'max', 'inverse', 'closed' then operands << [k.to_sym, v] when 'nodeKind' then operands << v.to_sym when 'object' then operands << value(v, ) when 'start' then operands << Start.new(ShEx::Algebra.from_shexj(v, )) when '@context' then [:context] = JSON::LD::Context.parse(v) [:base_uri] = [:context].base when 'shapes' operands << case v when Array [:shapes] + v.map {|vv| ShEx::Algebra.from_shexj(vv, )} else raise "Expected value of shapes #{v.inspect}" end when 'reference', 'include', 'stem', 'name' # Value may be :wildcard for stem operands << (v.is_a?(Symbol) ? v : iri(v, )) when 'predicate' then operands << iri(v, ) when 'extra', 'datatype' v = [v] unless v.is_a?(Array) operands << (v.map {|op| iri(op, )}).unshift(k.to_sym) when 'exclusions' v = [v] unless v.is_a?(Array) operands << v.map do |op| op.is_a?(Hash) ? ShEx::Algebra.from_shexj(op, ) : value(op, ) end.unshift(:exclusions) when 'min', 'max', 'inverse', 'closed', 'valueExpr', 'semActs', 'shapeExpr', 'shapeExprs', 'startActs', 'expression', 'expressions', 'annotations' v = [v] unless v.is_a?(Array) operands += v.map {|op| ShEx::Algebra.from_shexj(op, )} when 'code' operands << v when 'values' v = [v] unless v.is_a?(Array) operands += v.map do |op| Value.new(value(op, )) end end end new(*operands, label: label) end |
.iri(value, options) ⇒ RDF::Value
Create URIs
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/shex/algebra/operator.rb', line 433 def self.iri(value, ) # If we have a base URI, use that when constructing a new URI base_uri = [:base_uri] case value when Hash # A JSON-LD node reference v = [:context].(value) raise "Expected #{value.inspect} to be a JSON-LD Node Reference" unless JSON::LD::Utils.node_reference?(v) self.iri(v['@id'], ) when RDF::URI if base_uri && value.relative? base_uri.join(value) else value end when RDF::Value then value when /^_:/ then id = value[2..-1].to_s RDF::Node.intern(id) when /^(\w+):(\S+)$/ prefixes = .fetch(:prefixes, {}) if prefixes.has_key?($1) prefixes[$1].join($2) elsif RDF.type == value a = RDF.type.dup; a.lexical = 'a'; a elsif [:context] [:context].(value, vocab: true) else RDF::URI(value) end else if [:context] [:context].(value, document: true) elsif base_uri base_uri.join(value) elsif base_uri base_uri.join(value) else RDF::URI(value) end end end |
.value(value, options) ⇒ RDF::Value
Create Values, with “clever” matching to see if it might be a value, IRI or BNode.
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
# File 'lib/shex/algebra/operator.rb', line 491 def self.value(value, ) # If we have a base URI, use that when constructing a new URI case value when Hash # Either a value object or a node reference if value['uri'] iri(value['uri'], ) elsif value['value'] RDF::Literal(value['value'], datatype: value['type'], language: value['language']) else ShEx::Algebra.from_shexj(value, ) end else iri(value, ) end end |
Instance Method Details
#base_uri ⇒ HRDF::URI
Returns the Base URI defined for the parser, as specified or when parsing a BASE prologue element.
414 415 416 |
# File 'lib/shex/algebra/operator.rb', line 414 def base_uri @options[:base_uri] end |
#closed? ⇒ Boolean
Is this shape closed?
64 65 66 |
# File 'lib/shex/algebra/operator.rb', line 64 def closed? operands.include?(:closed) end |
#each_descendant(depth = 0) {|operator| ... } ⇒ Enumerator Also known as: descendants, each
Enumerate via depth-first recursive descent over operands, yielding each operator
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/shex/algebra/operator.rb', line 546 def each_descendant(depth = 0, &block) if block_given? case block.arity when 1 then block.call(self) else block.call(depth, self) end operands.each do |operand| case operand when Array operand.each do |op| op.each_descendant(depth + 1, &block) if op.respond_to?(:each_descendant) end else operand.each_descendant(depth + 1, &block) if operand.respond_to?(:each_descendant) end end end enum_for(:each_descendant) end |
#eql?(other) ⇒ Boolean Also known as: ==
535 536 537 |
# File 'lib/shex/algebra/operator.rb', line 535 def eql?(other) other.class == self.class && other.operands == self.operands end |
#first_ancestor(klass) ⇒ Operator
First ancestor operator of type ‘klass`
589 590 591 |
# File 'lib/shex/algebra/operator.rb', line 589 def first_ancestor(klass) parent.is_a?(klass) ? parent : parent.first_ancestor(klass) if parent end |
#focus ⇒ Object
On a result instance, the focus of the expression
86 87 88 |
# File 'lib/shex/algebra/operator.rb', line 86 def focus Array(operands.detect {|op| op.is_a?(Array) && op[0] == :focus} || [:focus])[1] end |
#focus=(node) ⇒ Object
89 90 91 92 |
# File 'lib/shex/algebra/operator.rb', line 89 def focus=(node) operands.delete_if {|op| op.is_a?(Array) && op[0] == :focus} operands << [:focus, node] end |
#inspect ⇒ String
Returns a developer-friendly representation of this operator.
528 529 530 |
# File 'lib/shex/algebra/operator.rb', line 528 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, operands.to_sse.gsub(/\s+/m, ' ')) end |
#iri(value, options = @options) ⇒ RDF::Value
Create URIs
425 426 427 |
# File 'lib/shex/algebra/operator.rb', line 425 def iri(value, = @options) self.class.iri(value, ) end |
#json_type ⇒ Object
306 307 308 |
# File 'lib/shex/algebra/operator.rb', line 306 def json_type self.class.name.split('::').last end |
#matched ⇒ Array<Statement>
On a result instance, the statements that matched this expression.
97 98 99 |
# File 'lib/shex/algebra/operator.rb', line 97 def matched Array((operands.detect {|op| op.is_a?(Array) && op[0] == :matched} || [:matched])[1..-1]) end |
#matched=(statements) ⇒ Object
100 101 102 103 |
# File 'lib/shex/algebra/operator.rb', line 100 def matched=(statements) operands.delete_if {|op| op.is_a?(Array) && op[0] == :matched} operands << statements.unshift(:matched) unless (statements || []).empty? end |
#message ⇒ String
On a result instance, the failure message. (failure only).
141 142 143 |
# File 'lib/shex/algebra/operator.rb', line 141 def (operands.detect {|op| op.is_a?(Array) && op[0] == :message} || [:message])[1..-1] end |
#message=(str) ⇒ Object
144 145 146 147 |
# File 'lib/shex/algebra/operator.rb', line 144 def (str) operands.delete_if {|op| op.is_a?(Array) && op[0] == :message} operands << [:message, str] end |
#not_matched(message, **opts, &block) ⇒ Object
Exception handling
167 168 169 170 171 172 |
# File 'lib/shex/algebra/operator.rb', line 167 def not_matched(, **opts, &block) expression = opts.fetch(:expression, self).satisfy(message: , **opts) exception = opts.fetch(:exception, ShEx::NotMatched) status(, **opts) {(block_given? ? block.call : "") + "expression: #{expression.to_sxp}"} raise exception.new(, expression: expression) end |
#not_satisfied(message, **opts) ⇒ Object
174 175 176 177 178 179 |
# File 'lib/shex/algebra/operator.rb', line 174 def not_satisfied(, **opts) expression = opts.fetch(:expression, self).satisfy(message: , **opts) exception = opts.fetch(:exception, ShEx::NotSatisfied) status(, **opts) {(block_given? ? block.call : "") + "expression: #{expression.to_sxp}"} raise exception.new(, expression: expression) end |
#operand(index = 0) ⇒ RDF::Term
Returns the operand at the given ‘index`.
214 215 216 |
# File 'lib/shex/algebra/operator.rb', line 214 def operand(index = 0) operands[index] end |
#parent ⇒ Operator
Parent expression, if any
574 |
# File 'lib/shex/algebra/operator.rb', line 574 def parent; @options[:parent]; end |
#parent=(operator) ⇒ Operator
Parent operator, if any
580 581 582 |
# File 'lib/shex/algebra/operator.rb', line 580 def parent=(operator) @options[:parent]= operator end |
#satisfiable? ⇒ Boolean
Does this operator include Satisfiable?
76 |
# File 'lib/shex/algebra/operator.rb', line 76 def satisfiable?; false; end |
#satisfied ⇒ Array<Operator>
On a result instance, the sub-expressions which were matched.
119 120 121 |
# File 'lib/shex/algebra/operator.rb', line 119 def satisfied Array((operands.detect {|op| op.is_a?(Array) && op[0] == :satisfied} || [:satisfied])[1..-1]) end |
#satisfied=(ops) ⇒ Object
122 123 124 125 |
# File 'lib/shex/algebra/operator.rb', line 122 def satisfied=(ops) operands.delete_if {|op| op.is_a?(Array) && op[0] == :satisfied} operands << ops.unshift(:satisfied) unless (ops || []).empty? end |
#satisfy(focus: nil, matched: nil, unmatched: nil, satisfied: nil, unsatisfied: nil, message: nil, **opts) ⇒ Operand
Duplication this operand, and add ‘matched`, `unmatched`, `satisfied`, and `unsatisfied` operands for accessing downstream.
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/shex/algebra/operator.rb', line 153 def satisfy(focus: nil, matched: nil, unmatched: nil, satisfied: nil, unsatisfied: nil, message: nil, **opts) log_debug(self.class.const_get(:NAME), "satisfied", **opts) unless expression = self.dup expression. = if expression.focus = focus if focus expression.matched = Array(matched) if matched expression.unmatched = Array(unmatched) if unmatched expression.satisfied = Array(satisfied) if satisfied expression.unsatisfied = Array(unsatisfied) if unsatisfied expression end |
#semact? ⇒ Boolean
Does this operator a SemAct?
82 |
# File 'lib/shex/algebra/operator.rb', line 82 def semact?; false; end |
#semantic_actions ⇒ Array<SemAct>
Semantic Actions
71 72 73 |
# File 'lib/shex/algebra/operator.rb', line 71 def semantic_actions operands.select {|o| o.is_a?(SemAct)} end |
#serialize_value(value) ⇒ String
Serialize a value, either as JSON, or as modififed N-Triples
512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/shex/algebra/operator.rb', line 512 def serialize_value(value) case value when RDF::Literal {'value' => value.to_s}. merge(value.has_datatype? ? {'type' => value.datatype.to_s} : {}). merge(value.has_language? ? {'language' => value.language.to_s} : {}) when RDF::Resource value.to_s else value.to_h end end |
#status(message, **opts, &block) ⇒ Object
187 188 189 190 |
# File 'lib/shex/algebra/operator.rb', line 187 def status(, **opts, &block) log_debug(self.class.const_get(:NAME).to_s + (@label ? "(#{@label})" : ""), , **opts, &block) true end |
#structure_error(message, **opts) ⇒ Object
181 182 183 184 185 |
# File 'lib/shex/algebra/operator.rb', line 181 def structure_error(, **opts) expression = opts.fetch(:expression, self) exception = opts.fetch(:exception, ShEx::StructureError) log_error(, depth: .fetch(:depth, 0), exception: exception) {"expression: #{expression.to_sxp}"} end |
#to_h ⇒ Hash
Create a hash version of the operator, suitable for turning into JSON.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/shex/algebra/operator.rb', line 317 def to_h obj = json_type == 'Schema' ? {'@context' => ShEx::CONTEXT, 'type' => json_type} : {'type' => json_type} obj['label'] = label.to_s if label operands.each do |op| case op when Array # First element should be a symbol case sym = op.first when :datatype, :pattern then obj[op.first.to_s] = op.last.to_s when :exclusions then obj['exclusions'] = Array(op[1..-1]).map {|v| serialize_value(v)} when :extra then (obj['extra'] ||= []).concat Array(op[1..-1]).map(&:to_s) # FIXME Shapes should be an array, not a hash when :shapes then obj['shapes'] = Array(op[1..-1]).map {|v| v.to_h} when :minlength, :maxlength, :length, :mininclusive, :maxinclusive, :minexclusive, :maxexclusive, :totaldigits, :fractiondigits then obj[op.first.to_s] = op.last.object when :min, :max then obj[op.first.to_s] = op.last when :base, :prefix # Ignore base and prefix when Symbol then obj[sym.to_s] = Array(op[1..-1]).map(&:to_h) else raise "Expected array to start with a symbol for #{self}" end when :wildcard then obj['stem'] = {'type' => 'Wildcard'} when Annotation then (obj['annotations'] ||= []) << op.to_h when SemAct then (obj[is_a?(Schema) ? 'startActs' : 'semActs'] ||= []) << op.to_h when Start then obj['start'] = op.operands.first.to_h when RDF::Value case self when TripleConstraint then obj['predicate'] = op.to_s when Stem, StemRange then obj['stem'] = op.to_s when Inclusion then obj['include'] = op.to_s when ShapeRef then obj['reference'] = op.to_s when SemAct then obj[op.is_a?(RDF::URI) ? 'name' : 'code'] = op.to_s else raise "How to serialize Value #{op.inspect} to json for #{self}" end when Symbol case self when NodeConstraint then obj['nodeKind'] = op.to_s when Shape then obj['closed'] = true when TripleConstraint then obj['inverse'] = true else raise "How to serialize Symbol #{op.inspect} to json for #{self}" end when TripleConstraint, EachOf, OneOf, Inclusion case self when EachOf, OneOf (obj['expressions'] ||= []) << op.to_h else obj['expression'] = op.to_h end when NodeConstraint case self when And, Or (obj['shapeExprs'] ||= []) << op.to_h else obj['valueExpr'] = op.to_h end when And, Or, Shape, Not, ShapeRef case self when And, Or (obj['shapeExprs'] ||= []) << op.to_h when TripleConstraint obj['valueExpr'] = op.to_h else obj['shapeExpr'] = op.to_h end when Value obj['values'] ||= [] Array(op).map {|o| o.operands}.flatten.each do |oo| obj['values'] << serialize_value(oo) end else raise "How to serialize #{op.inspect} to json for #{self}" end end obj end |
#to_json(options = nil) ⇒ Object
310 311 312 |
# File 'lib/shex/algebra/operator.rb', line 310 def to_json( = nil) self.to_h.to_json() end |
#to_sxp ⇒ String
Returns an S-Expression (SXP) representation of this operator
233 234 235 236 237 238 239 240 241 242 |
# File 'lib/shex/algebra/operator.rb', line 233 def to_sxp begin require 'sxp' # @see http://rubygems.org/gems/sxp rescue LoadError abort "SPARQL::Algebra::Operator#to_sxp requires the SXP gem (hint: `gem install sxp')." end require 'sparql/algebra/sxp_extensions' to_sxp_bin.to_sxp end |
#to_sxp_bin ⇒ Array
Returns the binary S-Expression (SXP) representation of this operator.
223 224 225 226 227 |
# File 'lib/shex/algebra/operator.rb', line 223 def to_sxp_bin [self.class.const_get(:NAME)] + (label ? [[:label, label]] : []) + (operands || []).map(&:to_sxp_bin) end |
#triple_expression? ⇒ Boolean
Does this operator include TripleExpression?
79 |
# File 'lib/shex/algebra/operator.rb', line 79 def triple_expression?; false; end |
#unmatched ⇒ Array<Statement>
On a result instance, the statements that did not match this expression (failure only).
108 109 110 |
# File 'lib/shex/algebra/operator.rb', line 108 def unmatched Array((operands.detect {|op| op.is_a?(Array) && op[0] == :unmatched} || [:unmatched])[1..-1]) end |
#unmatched=(statements) ⇒ Object
111 112 113 114 |
# File 'lib/shex/algebra/operator.rb', line 111 def unmatched=(statements) operands.delete_if {|op| op.is_a?(Array) && op[0] == :unmatched} operands << statements.unshift(:unmatched) unless (statements || []).empty? end |
#unsatisfied ⇒ Array<Operator>
On a result instance, the sub-satisfieables which were not satisfied. (failure only).
130 131 132 |
# File 'lib/shex/algebra/operator.rb', line 130 def unsatisfied Array((operands.detect {|op| op.is_a?(Array) && op[0] == :unsatisfied} || [:unsatisfied])[1..-1]) end |
#unsatisfied=(ops) ⇒ Object
133 134 135 136 |
# File 'lib/shex/algebra/operator.rb', line 133 def unsatisfied=(ops) operands.delete_if {|op| op.is_a?(Array) && op[0] == :unsatisfied} operands << ops.unshift(:unsatisfied) unless (ops || []).empty? end |
#validate! ⇒ SPARQL::Algebra::Expression
Validate all operands, operator specific classes should override for operator-specific validation
597 598 599 600 |
# File 'lib/shex/algebra/operator.rb', line 597 def validate! operands.each {|op| op.validate! if op.respond_to?(:validate!)} self end |
#value(value, options = @options) ⇒ RDF::Value
Create Values, with “clever” matching to see if it might be a value, IRI or BNode.
483 484 485 |
# File 'lib/shex/algebra/operator.rb', line 483 def value(value, = @options) self.class.value(value, ) end |