Sha256: 59d106a700ae212ca0896db312b9d097e6794b1e307e79d697e253f4792c14bf

Contents?: true

Size: 1.41 KB

Versions: 16

Compression:

Stored size: 1.41 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL `iri` operator.
    #
    # @example
    #     (base <http://example.org/> (project (?uri ?iri)
    #       (extend ((?uri (uri "uri")) (?iri (iri "iri")))
    #         (bgp))))
    #
    # @see http://www.w3.org/TR/rdf-sparql-query/#func-iri
    class IRI < Operator::Unary
      include Evaluatable

      NAME = [:iri, :uri]

      ##
      # The IRI function constructs an IRI by resolving the string argument (see RFC 3986 and RFC 3987 or any later RFC that superceeds RFC 3986 or RFC 3987). The IRI is resolved against the base IRI of the query and must result in an absolute IRI.
      #
      # The URI function is a synonym for IRI.
      #
      # If the function is passed an IRI, it returns the IRI unchanged.
      #
      # Passing any RDF term other than a simple literal, xsd:string or an IRI is an error.
      #
      # An implementation may normalize the IRI.
      #
      # @param  [RDF::Term] literal
      #   a simple literal
      # @return [RDF::URI]
      # @raise  [TypeError] if the operand is not a simple literal
      def apply(literal)
        raise TypeError, "expected an simple literal, but got #{literal.inspect}" unless literal.literal? && literal.simple?
        base = Operator.base_uri || RDF::URI("")
        base.join(literal.to_s)
      end

      Operator::URI = IRI
    end # IRI
  end # Operator
end; end # SPARQL::Algebra

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sparql-1.99.1 lib/sparql/algebra/operator/iri.rb
sparql-1.1.9.1 lib/sparql/algebra/operator/iri.rb
sparql-1.99.0 lib/sparql/algebra/operator/iri.rb
sparql-1.1.9 lib/sparql/algebra/operator/iri.rb
sparql-1.1.8 lib/sparql/algebra/operator/iri.rb
sparql-1.1.7 lib/sparql/algebra/operator/iri.rb
sparql-1.1.6 lib/sparql/algebra/operator/iri.rb
sparql-1.1.5 lib/sparql/algebra/operator/iri.rb
sparql-1.1.4 lib/sparql/algebra/operator/iri.rb
sparql-1.1.3 lib/sparql/algebra/operator/iri.rb
sparql-1.1.2.1 lib/sparql/algebra/operator/iri.rb
sparql-1.1.2 lib/sparql/algebra/operator/iri.rb
sparql-1.1.1 lib/sparql/algebra/operator/iri.rb
sparql-1.1.0 lib/sparql/algebra/operator/iri.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/iri.rb
sparql-1.0.8 lib/sparql/algebra/operator/iri.rb