Sha256: ad4032250f099314275dd590fd316ab7e51f715bb5f4a5ff90663c3880bcd472

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

module RelatonBib
  class << self
    def classification_hash_to_bib(ret)
      #ret[:classification] = [ret[:classification]] unless ret[:classification].is_a?(Array)
      #ret[:classification]&.each_with_index do |c, i|
      #ret[:classification][i] = RelatonBib::Classification.new(c)
      #end
      ret[:classification] and
        ret[:classification] = Classification.new(ret[:classification])
    end
  end

  class Classification
    # @return [String, NilClass]
    attr_reader :type

    # @return [String]
    attr_reader :value

    # @param type [String, NilClass]
    # @param value [String]
    def initialize(type: nil, value:)
      @type  = type
      @value = value
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      xml = builder.classification value
      xml[:type] = type if type
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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