Sha256: 2dd2aba1fbdccc9500adf1e311b4ffbfe8a6827770dd18a636e44280f7031013

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module NistBib
  class DocumentStatus
    STAGES = %w[
      draft-internal draft-wip draft-prelim draft-public final final-review
    ].freeze

    SUBSTAGES = %w[active retired withdrawn].freeze

    # @return [String]
    attr_reader :stage

    # @return [String, NilClass]
    attr_reader :substage

    # @return [String, NilClass]
    attr_reader :iteration

    # @param stage [String]
    # @param substage [String, NilClass]
    # @param iteration [String, NilClass]
    def initialize(stage:, substage: nil, iteration: nil)
      unless STAGES.include? stage
        raise ArgumentError, "invalid argument: stage (#{stage})"
      end

      if substage && !SUBSTAGES.include?(substage)
        raise ArgumentError, "invalid argument: substage (#{substage})"
      end

      @stage = stage
      @substage = substage
      @iteration = iteration
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nistbib-0.1.5 lib/nistbib/document_status.rb