lib/datacite/mapping/date.rb in datacite-mapping-0.3.0 vs lib/datacite/mapping/date.rb in datacite-mapping-0.4.0

- old
+ new

@@ -25,19 +25,25 @@ new :CREATED, 'Created' # @!parse ISSUED = Issued new :ISSUED, 'Issued' + # @!parse OTHER = Other + new :OTHER, 'Other' + # @!parse SUBMITTED = Submitted new :SUBMITTED, 'Submitted' # @!parse UPDATED = Updated new :UPDATED, 'Updated' # @!parse VALID = Valid new :VALID, 'Valid' + # @!parse WITHDRAWN = Withdrawn + new :WITHDRAWN, 'Withdrawn' + end # Represents a DataCite `<date/>` field, which can be a year, date (year-month-day or just year-month), # ISO8601 datetime, or [RKMS-ISO8601](http://www.ukoln.ac.uk/metadata/dcmi/collection-RKMS-ISO8601/) date range. # @@ -68,10 +74,11 @@ self.value = value end def type=(val) raise ArgumentError, 'Date type cannot be nil' unless val + @type = val end def value=(val) # rubocop:disable Metrics/AbcSize parts = val.to_s.split('/', -1) # negative limit so we don't drop trailing empty string @@ -87,10 +94,11 @@ @value = date_value ? date_value.to_s : "#{range_start}/#{range_end}" end def <=>(other) return nil unless other.class == self.class + %i[date_value range_start range_end type].each do |v| order = send(v) <=> other.send(v) return order if order.nonzero? end 0 @@ -105,9 +113,13 @@ end # @!attribute [rw] type # @return [DateType] the type of date. Cannot be nil. typesafe_enum_node :type, '@dateType', class: DateType + + # @!attribute [rw] date_information + # @return [String] information to clarify a date + text_node :date_information, '@dateInformation', default_value: nil # @!method value # @return [String] The value as a string. May be any [W3C DateTime format](http://www.w3.org/TR/NOTE-datetime). text_node :value, 'text()'