Sha256: 2eefec2b5fef67557268b5826e1c5e3e7e1b86c4ef10491e66eaaf13ac6bafb8

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 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

18 entries across 18 versions & 1 rubygems

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