class SPARQL::Algebra::Operator::Month

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 www.w3.org/TR/sparql11-query/#func-month

Constants

NAME

Public Instance Methods

apply(operand, **options) click to toggle source

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

# File lib/sparql/algebra/operator/month.rb, line 27
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.month)
end