Sha256: 3200a39f3810ec8b8aae38584dd0ce6c6fddf7a73b6567e9eec34e6a3e6d069e
Contents?: true
Size: 994 Bytes
Versions: 5
Compression:
Stored size: 994 Bytes
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL logical `month` operator. # # Returns the month part of `arg` as an integer. # # @example # (prefix ((: <http://example.org/>)) # (project (?s ?x) # (extend ((?x (month ?date))) # (bgp (triple ?s :date ?date))))) # # @see https://www.w3.org/TR/sparql11-query/#func-month class Month < Operator::Unary include Evaluatable NAME = :month ## # Returns the month 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.month) end end # Month end # Operator end; end # SPARQL::Algebra
Version data entries
5 entries across 5 versions & 1 rubygems