Sha256: 46a4ebceedca1acadd3582372cf8f7fa3b1c030c9f60f937fa60d6c1631fe55c

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

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

      NAME = :lcase

      ##
      # 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.downcase, :datatype => operand.datatype, :language => operand.language)
          else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
        end
      end
    end # LCase
  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/lcase.rb
sparql-1.1.4 lib/sparql/algebra/operator/lcase.rb
sparql-1.1.3 lib/sparql/algebra/operator/lcase.rb
sparql-1.1.2.1 lib/sparql/algebra/operator/lcase.rb
sparql-1.1.2 lib/sparql/algebra/operator/lcase.rb
sparql-1.1.1 lib/sparql/algebra/operator/lcase.rb
sparql-1.1.0 lib/sparql/algebra/operator/lcase.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/lcase.rb
sparql-1.0.8 lib/sparql/algebra/operator/lcase.rb
sparql-1.0.7 lib/sparql/algebra/operator/lcase.rb