class RDF::N3::Algebra::Math::Remainder

The subject is a pair of integers. The object is calculated by dividing the first number of the pair by the second and taking the remainder.

@see www.w3.org/TR/xpath-functions/#func-numeric-mod

Constants

NAME
URI

Public Instance Methods

resolve(list) click to toggle source

The math:remainder operator takes a pair of strings or numbers and calculates their remainder.

@param [RDF::N3::List] list @return [RDF::Term] @see RDF::N3::ListOperator#evaluate

# File lib/rdf/n3/algebra/math/remainder.rb, line 16
def resolve(list)
  list.to_a.map(&:as_number).reduce(&:%)
end
validate(list) click to toggle source

The list argument must be a pair of literals.

@param [RDF::N3::List] list @return [Boolean] @see RDF::N3::ListOperator#validate

Calls superclass method RDF::N3::Algebra::ListOperator#validate
# File lib/rdf/n3/algebra/math/remainder.rb, line 26
def validate(list)
  if super && list.all? {|li| li.is_a?(RDF::Literal) && li.as_number.is_a?(RDF::Literal::Integer)} && list.length == 2
    true
  else
    log_error(NAME) {"list is not a pair of integers: #{list.to_sxp}"}
    false
  end
end