Sha256: 9a5d9eaf2b52c5a3979c974a748de3150b9f6ca8e33e64a44b6a2a43eab776ac

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `tz` operator.
    #
    # Returns the timezone part of `arg` as a simple literal. Returns the empty string if there is no timezone.
    #
    # [121] BuiltInCall ::= ... | 'TZ' '(' Expression ')' 
    #
    # @example SPARQL Grammar
    #   PREFIX : <http://example.org/>
    #   SELECT ?s (TZ(?date) AS ?x) WHERE {
    #     ?s :date ?date
    #   }
    #
    # @example SSE
    #   (prefix
    #    ((: <http://example.org/>))
    #    (project (?s ?x)
    #     (extend ((?x (tz ?date)))
    #      (bgp (triple ?s :date ?date)))))
    #
    # @see https://www.w3.org/TR/sparql11-query/#func-tz
    class TZ < Operator::Unary
      include Evaluatable

      NAME = :tz

      ##
      # Returns the timezone part of arg as a simple literal. Returns the empty string if there is no timezone.
      #
      # @param  [RDF::Literal::Temporal] operand
      #   the operand
      # @return [RDF::Literal]
      # @raise  [TypeError] if the operand is not a simple literal
      def apply(operand, **options)
        raise TypeError, "expected an RDF::Literal::Temporal, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::Temporal)
        operand.tz
      end
      ##
      #
      # Returns a partial SPARQL grammar for this operator.
      #
      # @return [String]
      def to_sparql(**options)
        "TZ(" + operands.to_sparql(**options) + ")"
      end
    end # TZ
  end # Operator
end; end # SPARQL::Algebra

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sparql-3.3.1 lib/sparql/algebra/operator/tz.rb
sparql-3.3.0 lib/sparql/algebra/operator/tz.rb
sparql-3.2.6 lib/sparql/algebra/operator/tz.rb
sparql-3.2.5 lib/sparql/algebra/operator/tz.rb
sparql-3.2.4 lib/sparql/algebra/operator/tz.rb
sparql-3.2.3 lib/sparql/algebra/operator/tz.rb