class RDF::N3::Algebra::Math::Floor

The object is calculated as the subject downwards to a whole number.

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

Constants

NAME
URI

Public Instance Methods

resolve(resource, position:) click to toggle source

The math:floor operator takes string or number and calculates its floor.

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

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