Class: SPARQL::Algebra::Operator::IsNumeric
- Inherits:
-
Unary
- Object
- SPARQL::Algebra::Operator
- Unary
- 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.
Constant Summary collapse
- NAME =
:isnumeric
Constants inherited from Unary
Constants inherited from SPARQL::Algebra::Operator
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#apply(term) ⇒ RDF::Literal::Boolean
Returns
trueif the operand is anRDF::Literal::Numeric,falseotherwise.
Methods included from Evaluatable
#evaluate, #memoize, #replace_aggregate!, #replace_vars!
Methods inherited from Unary
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, base_uri, #base_uri, base_uri=, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, #optimize, #prefixes, prefixes, prefixes=, #rewrite, #to_sxp, #to_sxp_bin, #variable?
Methods included from Expression
cast, #constant?, #evaluate, extension, extensions, for, new, open, #optimize, parse, register_extension, #to_sxp_bin, #variable?
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Unary
Instance Method Details
#apply(term) ⇒ RDF::Literal::Boolean
Returns true if the operand is an RDF::Literal::Numeric, false otherwise.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sparql/algebra/operator/is_numeric.rb', line 29 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 |