Class: RDF::Literal::Year

Inherits:
Date
  • Object
show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-xsd-e532a0ab7189/lib/rdf/xsd/date.rb

Overview

gYear represents a gregorian calendar year. The value space of gYear is the set of Gregorian calendar years as defined in ยง 5.2.1 of [ISO 8601]. Specifically, it is a set of one-year long, non-periodic instances e.g. lexical 1999 to represent the whole year 1999, independent of how many months and days this year has.

Constant Summary collapse

DATATYPE =
RDF::XSD.gYear
GRAMMAR =
%r(\A(-?\d{4,})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
FORMAT =
'%Y%Z'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(value, datatype: nil, lexical: nil, **options) ⇒ Year

Returns a new instance of Year



47
48
49
50
51
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-xsd-e532a0ab7189/lib/rdf/xsd/date.rb', line 47

def initialize(value, datatype: nil, lexical: nil, **options)
  @string = lexical || value.to_s
  object = GRAMMAR.match(value.to_s) && ::Date.parse("#{$1}-01-01#{$2}")
  super(object, lexical: @string)
end