class RDF::N3::Algebra::Math::Rounded

The object is calulated as the subject rounded to the nearest integer.

Constants

NAME
URI

Public Instance Methods

resolve(resource, position:) click to toggle source

The math:rounded operator takes string or number rounds it to the next integer.

@param [RDF::Term] resource @param [:subject, :object] position @return [RDF::Term] @see RDF::N3::ResourceOperator#evaluate

# File lib/rdf/n3/algebra/math/rounded.rb, line 15
def resolve(resource, position:)
  case position
  when :subject
    return nil unless resource.literal?
    as_literal(resource.as_number.round)
  when :object
    return nil unless resource.literal? || resource.variable?
    resource
  end
end