Sha256: fbe58dcd0e8138fd2ae5a2e5fb1e216f5cdf87fe3c2857b46fd055f8d989e791

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'time'

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `now` operator.
    #
    # Returns an XSD dateTime value for the current query execution. All calls to this function in any one query execution must return the same value. The exact moment returned is not specified.
    #
    # @example
    #     (prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>))
    #       (ask (filter (= (datatype ?n) xsd:dateTime)
    #         (extend ((?n (now)))
    #           (bgp)))))
    #
    # @see https://www.w3.org/TR/sparql11-query/#func-now
    class Now < Operator::Nullary
      include Evaluatable

      NAME = :now

      ##
      # Returns an XSD dateTime value for the current query execution. All calls to this function in any one query execution must return the same value. The exact moment returned is not specified.
      #
      # @return [RDF::Literal::Double] random value
      def apply
        RDF::Literal(DateTime.now)
      end
    end # Now
  end # Operator
end; end # SPARQL::Algebra

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sparql-3.1.6 lib/sparql/algebra/operator/now.rb
sparql-3.1.5 lib/sparql/algebra/operator/now.rb
sparql-3.1.4 lib/sparql/algebra/operator/now.rb
sparql-3.1.3 lib/sparql/algebra/operator/now.rb
sparql-3.1.2 lib/sparql/algebra/operator/now.rb