Sha256: b600c4818560e3da58731279c8bcde187b32d4dab0385554d1f45bd130afa79f

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 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 http://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 http://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

10 entries across 10 versions & 1 rubygems

Version Path
sparql-1.1.5 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.4 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.3 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.2.1 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.2 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.1 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.0 lib/sparql/algebra/operator/strdt.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/strdt.rb
sparql-1.0.8 lib/sparql/algebra/operator/strdt.rb
sparql-1.0.7 lib/sparql/algebra/operator/strdt.rb