Sha256: 119864bb250c4257c77d72d05b92c9c696ad7f9827d9814b30c126123816efdd

Contents?: true

Size: 999 Bytes

Versions: 11

Compression:

Stored size: 999 Bytes

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `ceil` operator.
    #
    # @example
    #   (ceil ?x)
    #
    # @see http://www.w3.org/TR/sparql11-query/#func-ceil
    # @see http://www.w3.org/TR/xpath-functions/#func-ceil
    class Ceil < Operator::Unary
      include Evaluatable

      NAME = [:ceil]

      ##
      # Returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of `arg`. An error is raised if `arg` is not a numeric value.
      #
      # @param  [RDF::Literal] operand
      #   the operand
      # @return [RDF::Literal] literal of same type
      # @raise  [TypeError] if the operand is not a numeric value
      def apply(operand)
        case operand
          when RDF::Literal::Numeric then operand.ceil
          else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
        end
      end
    end # Ceil
  end # Operator
end; end # SPARQL::Algebra

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sparql-3.1.0 lib/sparql/algebra/operator/ceil.rb
sparql-3.0.2 lib/sparql/algebra/operator/ceil.rb
sparql-3.0.1 lib/sparql/algebra/operator/ceil.rb
sparql-3.0.0 lib/sparql/algebra/operator/ceil.rb
sparql-2.2.2 lib/sparql/algebra/operator/ceil.rb
sparql-2.2.1 lib/sparql/algebra/operator/ceil.rb
sparql-2.2.0 lib/sparql/algebra/operator/ceil.rb
sparql-2.1.0 lib/sparql/algebra/operator/ceil.rb
sparql-2.0.0 lib/sparql/algebra/operator/ceil.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/ceil.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/ceil.rb