Class: SPARQL::Algebra::Operator::Plus

Inherits:
Unary show all
Includes:
Evaluatable
Defined in:
lib/sparql/algebra/operator/plus.rb

Overview

The SPARQL numeric unary + operator.

Examples:

(+ ?x ?y)
(plus ?x ?y)

See Also:

Constant Summary

NAME =
[:+, :plus]

Constants inherited from Unary

Unary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands, #options

Instance Method Summary collapse

Methods included from Evaluatable

#evaluate, #memoize

Methods inherited from Unary

#initialize

Methods inherited from SPARQL::Algebra::Operator

arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, #optimize, #prefixes, prefixes, prefixes=, #to_sse, #to_sxp, #variable?

Methods included from Expression

cast, #constant?, #evaluate, for, new, open, #optimize, parse, #to_sse, #variable?

Constructor Details

This class inherits a constructor from SPARQL::Algebra::Operator::Unary

Instance Method Details

#apply(term) ⇒ RDF::Literal::Numeric

Returns the operand with its sign unchanged.

Parameters:

  • numeric (RDF::Literal::Numeric)

    a numeric literal

Returns:

  • (RDF::Literal::Numeric)

Raises:

  • (TypeError)

    if the operand is not a numeric literal



23
24
25
26
27
28
# File 'lib/sparql/algebra/operator/plus.rb', line 23

def apply(term)
  case term
    when RDF::Literal::Numeric then term
    else raise TypeError, "expected an RDF::Literal::Numeric, but got #{term.inspect}"
  end
end