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
relaton-bib-0.5.2 lib/relaton_bib/biblio_note.rb
relaton-bib-0.5.1 lib/relaton_bib/biblio_note.rb
relaton-bib-0.5.0 lib/relaton_bib/biblio_note.rb
relaton-bib-0.4.1 lib/relaton_bib/biblio_note.rb
relaton-bib-0.4.0 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.12 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.11 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.10 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.9 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.8 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.7 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.6 lib/relaton_bib/biblio_note.rb
relaton-bib-0.3.5 lib/relaton_bib/biblio_note.rb