Sha256: c786b341d01c02444f1f71890f217d77d591763ba2c4dead70f491e4a51a384c

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

# frozen_string_literal: true

module IsoBibItem
  # Localized string.
  class LocalizedString
    # @return [Array<String>] language Iso639 code
    attr_accessor :language

    # @return [Array<String>] script Iso15924 code
    attr_accessor :script

    # @return [String]
    attr_reader :content

    # @param content [String]
    # @param language [String] language code Iso639
    # @param script [String] script code Iso15924
    def initialize(content, language = nil, script = nil)
      @language = []
      @language << language if language
      @script = []
      @script << script if script
      @content = content
    end

    # @return [String]
    def to_s
      content
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.parent['language'] = language.join(',') if language.any?
      builder.parent['script']   = script.join(',') if script.any?
      builder.text content
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iso-bib-item-0.2.0 lib/iso_bib_item/localized_string.rb
iso-bib-item-0.1.11 lib/iso_bib_item/localized_string.rb
iso-bib-item-0.1.10 lib/iso_bib_item/localized_string.rb
iso-bib-item-0.1.9 lib/iso_bib_item/localized_string.rb