Sha256: bc6e75212c271715f3e3348506854e8f14e3d55b6d06f65ec4c64e1e723de3ec
Contents?: true
Size: 933 Bytes
Versions: 17
Compression:
Stored size: 933 Bytes
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL logical `hours` operator. # # @example # (prefix ((: <http://example.org/>)) # (project (?s ?x) # (extend ((?x (hours ?date))) # (bgp (triple ?s :date ?date))))) # # @see http://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. # # @param [RDF::Literal] operand # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal def apply(operand) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.hour) end end # Hours end # Operator end; end # SPARQL::Algebra
Version data entries
17 entries across 17 versions & 1 rubygems