Sha256: 09f7ceb213f803238f088b7251aa1eee6eaf9b222b3799cf9253234201d6fee6

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require "relaton_bib/localized_string"

module RelatonBib
  class << self
    def docstatus_hash_to_bib(ret)
      ret[:docstatus] and ret[:docstatus] =
        DocumentStatus.new(stage: ret[:docstatus][:stage],
                           substage: ret[:docstatus][:substage],
                           iteration: ret[:docstatus][:iteration])
    end
  end

  # 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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
relaton-bib-0.3.1 lib/relaton_bib/document_status.rb
relaton-bib-0.3.0 lib/relaton_bib/document_status.rb
relaton-bib-0.2.5 lib/relaton_bib/document_status.rb
relaton-bib-0.2.4 lib/relaton_bib/document_status.rb