Sha256: ef7c8408e2163847b752264856b229501e3be873cabb4874e4f2e8e76b8f2634

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module RelatonBib
  class << self
    def biblionote_hash_to_bib(ret)
      return unless ret[:biblionote]
      ret[:biblionote] = array(ret[:biblionote])
      (ret[:biblionote])&.each_with_index do |n, i|
        ret[:biblionote][i] =
          BiblioNote.new(content: n[:content], type: n[:type], 
                         language: n[:language], 
                         script: n[:script], format: n[:format])
      end
    end
  end

  class BiblioNote < FormattedString
    # @return [String]
    attr_reader :type

    # @param content [String]
    # @param type [String]
    # @param language [String] language code Iso639
    # @param script [String] script code Iso15924
    # @param format [String] the content type
    def initialize(content:, type: nil, language: nil, script: nil, format: nil)
      @type = type
      super content: content, language: language, script: script, format: format
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      xml = builder.note { super }
      xml[:type] = type if type
      xml
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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