Class: RDF::Literal::Year

Inherits:
Date show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-xsd-d4b9d6c7dd20/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

Constants inherited from RDF::Literal

FALSE, TRUE, ZERO

Instance Attribute Summary

Attributes inherited from RDF::Literal

#datatype, #language

Instance Method Summary collapse

Methods inherited from Date

#==, #canonicalize!, #has_timezone?, #humanize, #to_s, #tz, #valid?

Methods inherited from RDF::Literal

#==, #canonicalize!, #compatible?, #comperable_datatype?, #eql?, #escape, #has_datatype?, #has_language?, #hash, #humanize, #inspect, #literal?, #method_missing, #object, #plain?, #respond_to_missing?, #simple?, #squish, #squish!, #to_s, #valid?, #valid_extended?, #validate!, #value, #value_hash

Methods included from Term

#<=>, #==, #aggregate?, #compatible?, #eql?, #escape, #evaluate, #ndvars, #term?, #to_base, #to_term, #vars

Methods included from SPARQL::Algebra::Expression

cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Methods included from Value

#anonymous?, #canonicalize, #canonicalize!, #constant?, #graph?, #inspect, #inspect!, #invalid?, #iri?, #list?, #literal?, #node?, #resource?, #start_with?, #statement?, #term?, #to_nquads, #to_ntriples, #to_rdf, #to_term, #type_error, #uri?, #valid?, #validate!, #variable?

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-d4b9d6c7dd20/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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RDF::Literal