Sha256: 71504661e7af6f66afd9be66547962aa0ac1b45deae0a2e39a4be006f809e3a5

Contents?: true

Size: 942 Bytes

Versions: 11

Compression:

Stored size: 942 Bytes

Contents

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

      NAME = [:not, :'!']

      ##
      # Returns the logical `NOT` (inverse) of the operand.
      #
      # Note that this operator operates on the effective boolean value
      # (EBV) of its operand.
      #
      # @param  [RDF::Literal::Boolean] operand
      #   the operand
      # @return [RDF::Literal::Boolean] `true` or `false`
      # @raise  [TypeError] if the operand could not be coerced to a boolean literal
      def apply(operand)
        case bool = boolean(operand)
          when RDF::Literal::Boolean
            RDF::Literal(bool.false?)
          else super
        end
      end
    end # Not
  end # Operator
end; end # SPARQL::Algebra

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sparql-1.0.3 lib/sparql/algebra/operator/not.rb
sparql-1.0.2 lib/sparql/algebra/operator/not.rb
sparql-1.0.1 lib/sparql/algebra/operator/not.rb
sparql-1.0.0 lib/sparql/algebra/operator/not.rb
sparql-0.3.3 lib/sparql/algebra/operator/not.rb
sparql-0.3.2 lib/sparql/algebra/operator/not.rb
sparql-0.3.1 lib/sparql/algebra/operator/not.rb
sparql-0.3.0 lib/sparql/algebra/operator/not.rb
sparql-0.1.1 lib/sparql/algebra/operator/not.rb
sparql-0.1.0 lib/sparql/algebra/operator/not.rb
sparql-0.0.2 lib/sparql/algebra/operator/not.rb