Sha256: d1bf2a3fadc8577bcd027a1cb782906acc624367a495d921e89e619f8f57180f

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

require 'iso_bib_item/document_status'
require 'iso_bib_item/localized_string'

module IsoBibItem
  # module IsoDocumentStageCodes
  #   PREELIMINARY = '00'
  #   PROPOSAL     = '10'
  #   PREPARATORY  = '20'
  #   COMMITTE     = '30'
  #   ENQUIRY      = '40'
  #   APPROVAL     = '50'
  #   PUBLICATION  = '60'
  #   REVIEW       = '90'
  #   WITHDRAWAL   = '95'
  # end

  # module IsoDocumentSubstageCodes
  #   REGISTRATION              = '00'
  #   START_OF_MAIN_ACTION      = '20'
  #   COMPLETION_OF_MAIN_ACTION = '60'
  #   REPEAT_AN_EARLIER_PHASE   = '92'
  #   REPEAT_CURRENT_PHASE      = '92'
  #   ABADON                    = '98'
  #   PROCEED                   = '99'
  # end

  # ISO Document status.
  class IsoDocumentStatus < DocumentStatus
    # @return [String, NilClass]
    attr_reader :stage

    # @return [String, NilClass]
    attr_reader :substage

    # @return [Integer, NilClass]
    attr_reader :iteration

    # @param status [String, NilClass]
    # @param stage [String, NilClass]
    # @param substage [String, NilClass]
    # @param iteration [Integer, NilClass]
    def initialize(status: nil, stage: nil, substage: nil, iteration: nil)
      raise ArgumentError, 'status or stage is required' unless status || stage
      super LocalizedString.new(status)
      @stage     = stage
      @substage  = substage
      @iteration = iteration
    end

    # @param builder [Nkogiri::XML::Builder]
    def to_xml(builder)
      if stage
        builder.status do
          builder.stage stage
          builder.substage substage if substage
          builder.iteration iteration if iteration
        end
      else
        super
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iso-bib-item-0.2.1 lib/iso_bib_item/iso_document_status.rb
iso-bib-item-0.2.0 lib/iso_bib_item/iso_document_status.rb