Sha256: b9c99c8c2c599f79da4b2e75f957d324e8cb7c836682375187bc47f5989f814c

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `ucase` operator.
    #
    # @example
    #   (ucase ?x)
    #
    # @see http://www.w3.org/TR/sparql11-query/#func-ucase
    # @see http://www.w3.org/TR/xpath-functions/#func-ucase
    class UCase < Operator::Unary
      include Evaluatable

      NAME = :ucase

      ##
      # The LCASE function corresponds to the XPath fn:lower-case function. It returns a string literal whose lexical form is the lower case of the lexcial form of the argument.
      #
      # @param  [RDF::Literal] operand
      #   the operand
      # @return [RDF::Literal] literal of same type
      # @raise  [TypeError] if the operand is not a literal value
      def apply(operand)
        case operand
          when RDF::Literal then RDF::Literal(operand.to_s.upcase, :datatype => operand.datatype, :language => operand.language)
          else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
        end
      end
    end # UCase
  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/ucase.rb
sparql-1.1.4 lib/sparql/algebra/operator/ucase.rb
sparql-1.1.3 lib/sparql/algebra/operator/ucase.rb
sparql-1.1.2.1 lib/sparql/algebra/operator/ucase.rb
sparql-1.1.2 lib/sparql/algebra/operator/ucase.rb
sparql-1.1.1 lib/sparql/algebra/operator/ucase.rb
sparql-1.1.0 lib/sparql/algebra/operator/ucase.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/ucase.rb
sparql-1.0.8 lib/sparql/algebra/operator/ucase.rb
sparql-1.0.7 lib/sparql/algebra/operator/ucase.rb