Class: RDF::N3::Algebra::Time::GmTime

Inherits:
ResourceOperator
  • Object
show all
Defined in:
lib/rdf/n3/algebra/time/gm_time.rb

Overview

For a date-time format string, its time:gmtime is the result of formatting the Universal Time of processing in the format given. If the format string has zero length, then the ISOdate standard format is used. [ is time:gmtime of ""] the therefore the current date time. It will end with ā€œZā€ as a timezone code.

Constant Summary collapse

NAME =
:timeGmTime
URI =
RDF::N3::Time.gmTime

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Instance Method Summary collapse

Methods inherited from ResourceOperator

#as_literal, #execute, #input_operand, #valid?

Methods included from Builtin

#each, #evaluate, #hash, #input_operand, #rank, #to_uri

Instance Method Details

#resolve(resource, position:) ⇒ RDF::Term

The time:gmTime operator takes string or dateTime and returns current time formatted according to the subject.

Parameters:

  • resource (RDF::Term)
  • position (:subject, :object)

Returns:

See Also:

  • ResourceOperator#evaluate


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rdf/n3/algebra/time/gm_time.rb', line 17

def resolve(resource, position:)
  case position
  when :subject
    return nil unless resource.literal?
    resource = "%FT%T%:z" if resource.to_s.empty?
    RDF::Literal(DateTime.now.new_offset(0).strftime(resource.to_s))
  when :object
    return nil unless resource.literal? || resource.variable?
    resource
  end
end