Class: RDF::N3::Algebra::Math::LessThan

Inherits:
ResourceOperator
  • Object
show all
Defined in:
lib/rdf/n3/algebra/math/less_than.rb

Overview

True iff the subject is a string representation of a number which is less than the number of which the object is a string representation.

Direct Known Subclasses

NotLessThan

Constant Summary collapse

NAME =
:mathLessThan
URI =
RDF::N3::Math.lessThan

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Instance Method Summary collapse

Methods inherited from ResourceOperator

#as_literal, #execute, #valid?

Methods included from Builtin

#each, #evaluate, #hash, #rank, #to_uri

Instance Method Details

#apply(term1, term2) ⇒ RDF::Literal::Boolean

Returns TRUE if term1 is less than term2.

Parameters:

Returns:

  • (RDF::Literal::Boolean)

    true or false

Raises:

  • (TypeError)

    if either operand is not an RDF term or operands are not comperable

See Also:

  • Term#==


37
38
39
# File 'lib/rdf/n3/algebra/math/less_than.rb', line 37

def apply(term1, term2)
  RDF::Literal(term1 < term2)
end

#input_operandObject

Both subject and object are inputs.



22
23
24
# File 'lib/rdf/n3/algebra/math/less_than.rb', line 22

def input_operand
  RDF::N3::List.new(values: operands)
end

#resolve(resource, position:) ⇒ RDF::Term

Resolves inputs as numbers.

Parameters:

  • resource (RDF::Term)
  • position (:subject, :object)

Returns:

See Also:

  • ResourceOperator#evaluate


17
18
19
# File 'lib/rdf/n3/algebra/math/less_than.rb', line 17

def resolve(resource, position:)
  resource.as_number if resource.term?
end