Sha256: 720c0b62cbe57da7462873c2280fbc867748f282dfe531523575ad5259df8e54

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

module RDF::N3::Algebra::Str
  # True iff the subject string contains the object string, with the comparison done ignoring the difference between upper case and lower case characters.
  class ContainsIgnoringCase < RDF::N3::Algebra::ResourceOperator
    NAME = :strContainsIgnoringCase
    URI = RDF::N3::Str.containsIgnoringCase

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-n3-3.3.0 lib/rdf/n3/algebra/str/contains_ignoring_case.rb
rdf-n3-3.2.1 lib/rdf/n3/algebra/str/contains_ignoring_case.rb
rdf-n3-3.2.0 lib/rdf/n3/algebra/str/contains_ignoring_case.rb
rdf-n3-3.1.2 lib/rdf/n3/algebra/str/contains_ignoring_case.rb