Sha256: 75013788c0007bee50ab95e005747aa57a7ad12f672bb1871ffbad05b1846a7e

Contents?: true

Size: 1.01 KB

Versions: 25

Compression:

Stored size: 1.01 KB

Contents

module RelatonBib
  class Validity
    FORMAT = "%Y-%m-%d %H:%M"

    # @return [Time, NilClass]
    attr_reader :begins

    # @return [Time, NilClass]
    attr_reader :ends

    # @return [Time, NilClass]
    attr_reader :revision

    # @param begins [Time, NilClass]
    # @param ends [Time, NilClass]
    # @param revision [Time, NilClass]
    def initialize(begins: nil, ends: nil, revision: nil)
      @begins   = begins
      @ends     = ends
      @revision = revision
    end

    # @param [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.validity do
        builder.validityBegins begins.strftime(FORMAT) if begins
        builder.validityEnds ends.strftime(FORMAT) if ends
        builder.revision revision.strftime(FORMAT) if revision
      end
    end

    # @return [Hash]
    def to_hash
      hash = {}
      hash["begins"] = begins.strftime(FORMAT) if begins
      hash["ends"] = ends.strftime(FORMAT) if ends
      hash["revision"] = revision.strftime(FORMAT) if revision
      hash
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/relaton-bib-1.2.4/lib/relaton_bib/validity.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/relaton-bib-1.2.4/lib/relaton_bib/validity.rb
relaton-bib-1.2.4 lib/relaton_bib/validity.rb
relaton-bib-1.2.2 lib/relaton_bib/validity.rb
relaton-bib-1.2.1 lib/relaton_bib/validity.rb
relaton-bib-1.2.0 lib/relaton_bib/validity.rb
relaton-bib-1.1.1 lib/relaton_bib/validity.rb
relaton-bib-1.1.0 lib/relaton_bib/validity.rb
relaton-bib-1.0.4 lib/relaton_bib/validity.rb
relaton-bib-1.0.3 lib/relaton_bib/validity.rb
relaton-bib-1.0.2 lib/relaton_bib/validity.rb
relaton-bib-1.0.1 lib/relaton_bib/validity.rb
relaton-bib-1.0.0 lib/relaton_bib/validity.rb
relaton-bib-0.9.2 lib/relaton_bib/validity.rb
relaton-bib-0.9.1 lib/relaton_bib/validity.rb
relaton-bib-0.9.0 lib/relaton_bib/validity.rb
relaton-bib-0.8.1 lib/relaton_bib/validity.rb
relaton-bib-0.8.0 lib/relaton_bib/validity.rb
relaton-bib-0.7.0 lib/relaton_bib/validity.rb
relaton-bib-0.6.0 lib/relaton_bib/validity.rb