Sha256: a9241f3c9160c2056c9b469b02cc81a4194369ebaf621830ae1dbca04d059724

Contents?: true

Size: 1.06 KB

Versions: 18

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

18 entries across 18 versions & 1 rubygems

Version Path
sparql-3.1.0 lib/sparql/algebra/operator/strlang.rb
sparql-3.0.2 lib/sparql/algebra/operator/strlang.rb
sparql-3.0.1 lib/sparql/algebra/operator/strlang.rb
sparql-3.0.0 lib/sparql/algebra/operator/strlang.rb
sparql-2.2.2 lib/sparql/algebra/operator/strlang.rb
sparql-2.2.1 lib/sparql/algebra/operator/strlang.rb
sparql-2.2.0 lib/sparql/algebra/operator/strlang.rb
sparql-2.1.0 lib/sparql/algebra/operator/strlang.rb
sparql-2.0.0 lib/sparql/algebra/operator/strlang.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/strlang.rb
sparql-1.99.1 lib/sparql/algebra/operator/strlang.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/strlang.rb
sparql-1.1.9.1 lib/sparql/algebra/operator/strlang.rb
sparql-1.99.0 lib/sparql/algebra/operator/strlang.rb
sparql-1.1.9 lib/sparql/algebra/operator/strlang.rb
sparql-1.1.8 lib/sparql/algebra/operator/strlang.rb
sparql-1.1.7 lib/sparql/algebra/operator/strlang.rb
sparql-1.1.6 lib/sparql/algebra/operator/strlang.rb