Sha256: de2b2409bc94d396a961ca9f1e27f7a55dc46b0ea389c2095af20e6c253e86f4
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL logical `hours` operator. # # [121] BuiltInCall ::= ... | 'HOURS' '(' Expression ')' # # @example SPARQL Grammar # PREFIX : <http://example.org/> # SELECT ?s (HOURS(?date) AS ?x) WHERE { # ?s :date ?date # } # # @example SSE # (prefix # ((: <http://example.org/>)) # (project (?s ?x) # (extend ((?x (hours ?date))) # (bgp (triple ?s :date ?date))))) # # @see https://www.w3.org/TR/sparql11-query/#func-hours class Hours < Operator::Unary include Evaluatable NAME = :hours ## # Returns the hours part of `arg` as an integer. The value is as given in the lexical form of the XSD dateTime. # # @param [RDF::Literal] operand # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.hour) end ## # # Returns a partial SPARQL grammar for this operator. # # @return [String] def to_sparql(**options) "HOURS(#{operands.last.to_sparql(**options)})" end end # Hours end # Operator end; end # SPARQL::Algebra
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sparql-3.2.1 | lib/sparql/algebra/operator/hours.rb |
sparql-3.2.0 | lib/sparql/algebra/operator/hours.rb |