Sha256: 92479f78d7e160d7fd49d9a7034ca021b8a2578a18d4cbf0bf4c671925ce1688

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL `strlang` operator.
    #
    # @example
    #     (prefix ((: <http://example.org/>))
    #       (project (?s ?s2)
    #         (extend ((?s2 (strlang ?str "en-US")))
    #           (filter (langMatches (lang ?str) "en")
    #             (bgp (triple ?s :str ?str))))))
    #
    # @see http://www.w3.org/TR/sparql11-query/#func-strlang
    class StrLang < Operator::Binary
      include Evaluatable

      NAME = :strlang

      ##
      # Constructs a literal with lexical form and type as specified by the arguments.
      #
      # @param  [RDF::Literal] value
      #   a literal
      # @param  [RDF::Literal] langTag
      #   datatype
      # @return [RDF::Literal] a datatyped literal
      # @see http://www.w3.org/TR/sparql11-query/#func-strlang
      def apply(value, langTag)
        raise TypeError, "Literal #{value.inspect} is not simple" unless value.simple?
        RDF::Literal.new(value.to_s, :language => langTag.to_s)
      end
    end # StrLang
  end # Operator
end; end # SPARQL::Algebra

Version data entries

8 entries across 8 versions & 1 rubygems

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