class RDF::N3::Algebra::Time::Year

For a date-time, its time:year is the year component.

@see www.w3.org/TR/xpath-functions/#func-year-from-dateTime

Constants

NAME
URI

Public Instance Methods

resolve(resource, position:) click to toggle source

The time:year operator takes string or dateTime and extracts the year component.

@param [RDF::Term] resource @param [:subject, :object] position @return [RDF::Term] @see RDF::N3::ResourceOperator#evaluate

# File lib/rdf/n3/algebra/time/year.rb, line 17
def resolve(resource, position:)
  case position
  when :subject
    return nil unless resource.literal?
    resource.as_datetime.year
  when :object
    return nil unless resource.literal? || resource.variable?
    resource
  end
end