Class: SPARQL::Algebra::Operator::Year
- Includes:
- Evaluatable
- Defined in:
- lib/sparql/algebra/operator/year.rb
Overview
The SPARQL logical year operator.
Returns the year part of arg as an integer.
[121] BuiltInCall ::= ... | 'YEAR' '(' Expression ')'
Constant Summary collapse
- NAME =
:year
Instance Method Summary collapse
-
#apply(operand, **options) ⇒ RDF::Literal::Temporal
Returns the year part of arg as an integer.
-
#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(operand, **options) ⇒ RDF::Literal::Temporal
Returns the year part of arg as an integer.
36 37 38 39 |
# File 'lib/sparql/algebra/operator/year.rb', line 36 def apply(operand, **) raise TypeError, "expected an RDF::Literal::Temporal, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::Temporal) RDF::Literal(operand.object.year) end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
46 47 48 |
# File 'lib/sparql/algebra/operator/year.rb', line 46 def to_sparql(**) "YEAR(#{operands.last.to_sparql(**)})" end |