class RDF::N3::Algebra::Math::AbsoluteValue
The object is calulated as the absolute value of the subject.
Constants
- NAME
- URI
Public Instance Methods
input_operand()
click to toggle source
Input is either the subject or object
@return [RDF::Term]
# File lib/rdf/n3/algebra/math/absolute_value.rb, line 32 def input_operand RDF::N3::List.new(values: operands) end
resolve(resource, position:)
click to toggle source
The math:absoluteValue operator takes string or number and calculates its absolute value.
@param [RDF::Term] resource @param [:subject, :object] position @return [RDF::Term] @see RDF::N3::ResourceOperator#evaluate
# 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