Sha256: a0e90e563864849a9bfd8313b370e16f6fe4bd2e5486d787888e5f01462f0959

Contents?: true

Size: 1.05 KB

Versions: 23

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require "relaton_bib/localized_string"

module RelatonBib
  # Document status.
  class DocumentStatus
    # @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)
      @stage = stage
      @substage = substage
      @iteration = iteration
    end

    # @param [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.status do
        # FormattedString.instance_method(:to_xml).bind(status).call builder
        builder.stage stage
        builder.substage substage if substage
        builder.iteration iteration unless iteration.to_s.empty?
      end
    end

    # @return [Hash]
    def to_hash
      hash = { "stage" => stage }
      hash["substage"] = substage if substage
      hash["iteration"] = iteration if iteration
      hash
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
relaton-bib-1.0.2 lib/relaton_bib/document_status.rb
relaton-bib-1.0.1 lib/relaton_bib/document_status.rb
relaton-bib-1.0.0 lib/relaton_bib/document_status.rb
relaton-bib-0.9.2 lib/relaton_bib/document_status.rb
relaton-bib-0.9.1 lib/relaton_bib/document_status.rb
relaton-bib-0.9.0 lib/relaton_bib/document_status.rb
relaton-bib-0.8.1 lib/relaton_bib/document_status.rb
relaton-bib-0.8.0 lib/relaton_bib/document_status.rb
relaton-bib-0.7.0 lib/relaton_bib/document_status.rb
relaton-bib-0.6.0 lib/relaton_bib/document_status.rb
relaton-bib-0.5.2 lib/relaton_bib/document_status.rb
relaton-bib-0.5.1 lib/relaton_bib/document_status.rb
relaton-bib-0.5.0 lib/relaton_bib/document_status.rb
relaton-bib-0.4.1 lib/relaton_bib/document_status.rb
relaton-bib-0.4.0 lib/relaton_bib/document_status.rb
relaton-bib-0.3.12 lib/relaton_bib/document_status.rb
relaton-bib-0.3.11 lib/relaton_bib/document_status.rb
relaton-bib-0.3.10 lib/relaton_bib/document_status.rb
relaton-bib-0.3.9 lib/relaton_bib/document_status.rb
relaton-bib-0.3.8 lib/relaton_bib/document_status.rb