Class: RDF::N3::Algebra::Math::Negation

Inherits:
ResourceOperator
  • Object
show all
Includes:
Builtin
Defined in:
lib/rdf/n3/algebra/math/negation.rb

Overview

The subject or object is calculated to be the negation of the other.

Constant Summary collapse

NAME =
:mathNegation
URI =
RDF::N3::Math.negation

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Instance Method Summary collapse

Methods included from Builtin

#each, #evaluate, #hash, #rank, #to_uri

Methods inherited from ResourceOperator

#as_literal, #execute, #valid?

Instance Method Details

#input_operandRDF::Term

Input is either the subject or object

Returns:



34
35
36
# File 'lib/rdf/n3/algebra/math/negation.rb', line 34

def input_operand
  RDF::N3::List.new(values: operands)
end

#resolve(resource, position:) ⇒ RDF::Term

The math:negation operator takes may have either a bound subject or object.

Parameters:

  • resource (RDF::Term)
  • position (:subject, :object)

Returns:

See Also:

  • ResourceOperator#evaluate


19
20
21
22
23
24
25
26
27
28
# File 'lib/rdf/n3/algebra/math/negation.rb', line 19

def resolve(resource, position:)
  case resource
  when RDF::Query::Variable
    resource
  when RDF::Literal
    as_literal(-resource.as_number)
  else
    nil
  end
end