Sha256: d909413a2a8f047aa5ffd3c915b9f395180426639aff0465d430f0ce740e638e

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL `strdt` operator.
    #
    # @example
    #     (project (?s ?str1)
    #       (extend ((?str1 (strdt ?str xsd:string)))
    #         (filter (langMatches (lang ?str) "en")
    #           (bgp (triple ?s :str ?str))))))
    #
    # @see https://www.w3.org/TR/sparql11-query/#func-strdt
    class StrDT < Operator::Binary
      include Evaluatable

      NAME = :strdt

      ##
      # Constructs a literal with lexical form and type as specified by the arguments.
      #
      # @param  [RDF::Literal] value
      #   a literal
      # @param  [RDF::URI] datatypeIRI
      #   datatype
      # @return [RDF::Literal] a datatyped literal
      # @see https://www.w3.org/TR/sparql11-query/#func-strdt
      def apply(value, datatypeIRI)
        raise TypeError, "Literal #{value.inspect} is not simple" unless value.simple?
        RDF::Literal.new(value.to_s, datatype: datatypeIRI)
      end
    end # StrDT
  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/strdt.rb
sparql-3.1.5 lib/sparql/algebra/operator/strdt.rb
sparql-3.1.4 lib/sparql/algebra/operator/strdt.rb
sparql-3.1.3 lib/sparql/algebra/operator/strdt.rb
sparql-3.1.2 lib/sparql/algebra/operator/strdt.rb