Class: RDF::N3::Algebra::Math::AbsoluteValue
- Inherits:
-
ResourceOperator
- Object
- SPARQL::Algebra::Operator::Binary
- ResourceOperator
- RDF::N3::Algebra::Math::AbsoluteValue
- Defined in:
- lib/rdf/n3/algebra/math/absolute_value.rb
Overview
The object is calulated as the absolute value of the subject.
Constant Summary collapse
Instance Attribute Summary
Attributes included from Enumerable
Instance Method Summary collapse
-
#input_operand ⇒ RDF::Term
Input is either the subject or object.
-
#resolve(resource, position:) ⇒ RDF::Term
The math:absoluteValue operator takes string or number and calculates its absolute value.
Methods inherited from ResourceOperator
#as_literal, #execute, #valid?
Methods included from Builtin
#each, #evaluate, #hash, #rank, #to_uri
Instance Method Details
#input_operand ⇒ RDF::Term
Input is either the subject or object
32 33 34 |
# File 'lib/rdf/n3/algebra/math/absolute_value.rb', line 32 def input_operand RDF::N3::List.new(values: operands) end |
#resolve(resource, position:) ⇒ RDF::Term
The math:absoluteValue operator takes string or number and calculates its absolute value.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rdf/n3/algebra/math/absolute_value.rb', line 17 def resolve(resource, position:) case position when :subject return nil unless resource.literal? as_literal(resource.as_number.abs) when :object return nil unless resource.literal? || resource.variable? resource end end |