Sha256: f5a34e8fbc2afc59f2c7bfecb44385940f8ca12c09e5a89cf1ebd7572407e8e5

Contents?: true

Size: 902 Bytes

Versions: 33

Compression:

Stored size: 902 Bytes

Contents

module RelatonBib
  class BiblioNote < FormattedString
    # @return [String, NilClass]
    attr_reader :type

    # @param content [String]
    # @param type [String, NilClass]
    # @param language [String, NilClass] language code Iso639
    # @param script [String, NilClass] script code Iso15924
    # @param format [String, NilClass] the content format
    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

    # @return [Hash]
    def to_hash
      hash = super
      return hash unless type

      hash = { "content" => hash } if hash.is_a? String
      hash["type"] = type
      hash
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/relaton-bib-1.2.4/lib/relaton_bib/biblio_note.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/relaton-bib-1.2.4/lib/relaton_bib/biblio_note.rb
relaton-bib-1.2.4 lib/relaton_bib/biblio_note.rb
relaton-bib-1.2.2 lib/relaton_bib/biblio_note.rb
relaton-bib-1.2.1 lib/relaton_bib/biblio_note.rb
relaton-bib-1.2.0 lib/relaton_bib/biblio_note.rb
relaton-bib-1.1.1 lib/relaton_bib/biblio_note.rb
relaton-bib-1.1.0 lib/relaton_bib/biblio_note.rb
relaton-bib-1.0.4 lib/relaton_bib/biblio_note.rb
relaton-bib-1.0.3 lib/relaton_bib/biblio_note.rb
relaton-bib-1.0.2 lib/relaton_bib/biblio_note.rb
relaton-bib-1.0.1 lib/relaton_bib/biblio_note.rb
relaton-bib-1.0.0 lib/relaton_bib/biblio_note.rb
relaton-bib-0.9.2 lib/relaton_bib/biblio_note.rb
relaton-bib-0.9.1 lib/relaton_bib/biblio_note.rb
relaton-bib-0.9.0 lib/relaton_bib/biblio_note.rb
relaton-bib-0.8.1 lib/relaton_bib/biblio_note.rb
relaton-bib-0.8.0 lib/relaton_bib/biblio_note.rb
relaton-bib-0.7.0 lib/relaton_bib/biblio_note.rb
relaton-bib-0.6.0 lib/relaton_bib/biblio_note.rb