Sha256: 35b10c7a45a81211eea966dfc45d48afe6110186aafd31bb679b3a539e20ed25

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module IsoBibItem
  # ISO localized string.
  class IsoLocalizedTitle
    # @return [String]
    attr_reader :title_intro

    # @return [String]
    attr_reader :title_main

    # @return [String]
    attr_reader :title_part

    # @return [String] language code Iso639
    attr_reader :language

    # @return [String] script code Iso15924
    attr_reader :script

    # @param title_intro [String]
    # @param title_main [String]
    # @param title_part [String]
    # @param language [String] language Iso639 code
    # @param script [String] script Iso15924 code
    def initialize(title_intro:, title_main:, title_part: nil, language:, script:)
      @title_intro = title_intro
      @title_main  = title_main
      @title_part  = title_part
      @language    = language
      @script      = script
    end

    # @return [String]
    def to_s
      "#{@title_intro} -- #{@title_main} -- #{@title_part}"
    end

    def to_xml(builder)
      builder.title(format: 'text/plain', language: language, script: script) do
        builder.text to_s
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iso-bib-item-0.1.1 lib/iso_bib_item/iso_localized_title.rb