Class: SPARQL::Algebra::Operator::Adjust
- Includes:
- Evaluatable
- Defined in:
- lib/sparql/algebra/operator/adjust.rb
Overview
The SPARQL adjust operator.
[121] BuiltInCall ::= ... | 'ADJUST' '(' Expression ',' Expression ')'
Constant Summary collapse
- NAME =
[:adjust]
Instance Method Summary collapse
-
#apply(operand, duration, **options) ⇒ RDF::Literal
Returns the first operand adjusted by the dayTimeDuration of the second operand.
-
#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, duration, **options) ⇒ RDF::Literal
Returns the first operand adjusted by the dayTimeDuration of the second operand
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sparql/algebra/operator/adjust.rb', line 42 def apply(operand, duration, **) case operand when RDF::Literal::Temporal case duration when RDF::Literal::DayTimeDuration operand.adjust_to_timezone(duration) when RDF::Literal raise TypeError, "expected second operand to be an empty literal, but got #{duration.inspect}" unless duration.to_s.empty? operand.adjust_to_timezone(nil) else raise TypeError, "expected second operand to be an RDF::Literal::DayTimeDuration, but got #{duration.inspect}" end else raise TypeError, "expected first operand to be an RDF::Literal::Temporal, but got #{operand.inspect}" end end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
64 65 66 |
# File 'lib/sparql/algebra/operator/adjust.rb', line 64 def to_sparql(**) "ADJUST(#{operands.to_sparql(delimiter: ', ', **)})" end |