Class: SPARQL::Algebra::Operator::IsNumeric
- Includes:
- Evaluatable
- Defined in:
- lib/sparql/algebra/operator/is_numeric.rb
Overview
The SPARQL isNumeric operator.
Note numeric denotes typed literals with datatypes xsd:integer, xsd:decimal, xsd:float, and xsd:double, not derived types.
[121] BuiltInCall ::= ... | 'isNumeric' '(' Expression ')'
Constant Summary collapse
- NAME =
:isNumeric
Instance Method Summary collapse
-
#apply(term, **options) ⇒ RDF::Literal::Boolean
Returns
trueif the operand is anRDF::Literal::Numeric,falseotherwise. -
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
Methods included from Evaluatable
#evaluate, #memoize, #replace_aggregate!, #replace_vars!
Instance Method Details
#apply(term, **options) ⇒ RDF::Literal::Boolean
Returns true if the operand is an RDF::Literal::Numeric, false
otherwise.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sparql/algebra/operator/is_numeric.rb', line 37 def apply(term, **) case term when RDF::Literal::NonPositiveInteger then RDF::Literal::FALSE when RDF::Literal::NonNegativeInteger then RDF::Literal::FALSE when RDF::Literal::Long then RDF::Literal::FALSE when RDF::Literal::Numeric then RDF::Literal::TRUE when RDF::Term then RDF::Literal::FALSE else raise TypeError, "expected an RDF::Term, but got #{term.inspect}" end end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
53 54 55 |
# File 'lib/sparql/algebra/operator/is_numeric.rb', line 53 def to_sparql(**) "isNumeric(" + operands.first.to_sparql(**) + ")" end |