Sha256: 4455ab94a7eed3d8096348c9ed93c1c37519e8bccb4270f42af72c52776c7510
Contents?: true
Size: 717 Bytes
Versions: 1
Compression:
Stored size: 717 Bytes
Contents
# frozen_string_literal: true require 'time' module IsoBibItem # Bibliographic date. class BibliographicDate # @return [String] attr_reader :type # @return [Time] attr_reader :from # @return [Time] attr_reader :to # @param type [String] "published", "accessed", "created", "activated" # @param from [String] # @param to [String] def initialize(type:, from:, to: nil) @type = type @from = Time.strptime(from, '%Y-%d') @to = Time.strptime(to, '%Y-%d') if to end def to_xml(builder, **opts) builder.date(type: type) do builder.from(opts[:no_year] ? '--' : from.year) builder.to to.year if to end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iso-bib-item-0.1.0 | lib/iso_bib_item/bibliographic_date.rb |