Sha256: 2e47bf2fb82a2b80053896e8ca42a6c9b8519157fcd1eaaf9cb564e29047cf5b

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 Bytes

Contents

module RDF::N3::Algebra::Log
  ##
  # True if the subject and object are the same RDF node (symbol or literal).  Do not confuse with owl:sameAs. A cwm built-in logical operator, RDF graph level.
  class EqualTo < RDF::N3::Algebra::ResourceOperator
    NAME = :logEqualTo
    URI = RDF::N3::Log.equalTo

    ##
    # Resolves inputs as terms.
    #
    # @param [RDF::Term] resource
    # @param [:subject, :object] position
    # @return [RDF::Literal]
    # @see RDF::N3::ResourceOperator#evaluate
    def resolve(resource, position:)
      resource if resource.term?
    end

    # Both subject and object are inputs.
    def input_operand
      RDF::N3::List.new(values: operands)
    end

    ##
    # @param  [RDF::Literal] left
    #   a literal
    # @param  [RDF::Literal] right
    #   a literal
    # @return [RDF::Literal::Boolean]
    def apply(left, right)
      RDF::Literal(left.sameTerm?(right))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-n3-3.3.0 lib/rdf/n3/algebra/log/equal_to.rb
rdf-n3-3.2.1 lib/rdf/n3/algebra/log/equal_to.rb
rdf-n3-3.2.0 lib/rdf/n3/algebra/log/equal_to.rb
rdf-n3-3.1.2 lib/rdf/n3/algebra/log/equal_to.rb