Class: IsoBibItem::IsoLocalizedTitle

Inherits:
Object
  • Object
show all
Defined in:
lib/iso_bib_item/iso_localized_title.rb

Overview

ISO localized string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title_intro:, title_main:, title_part: nil, language:, script:) ⇒ IsoLocalizedTitle

Returns a new instance of IsoLocalizedTitle.

Parameters:

  • title_intro (String)
  • title_main (String)
  • title_part (String) (defaults to: nil)
  • language (String)

    language Iso639 code

  • script (String)

    script Iso15924 code



26
27
28
29
30
31
32
33
34
35
# File 'lib/iso_bib_item/iso_localized_title.rb', line 26

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
  @title_main = '[ -- ]' if @title_main.nil? || @title_main.empty?
  # "[ -- ]" # title cannot be nil
end

Instance Attribute Details

#languageString (readonly)

Returns language code Iso639.

Returns:

  • (String)

    language code Iso639



16
17
18
# File 'lib/iso_bib_item/iso_localized_title.rb', line 16

def language
  @language
end

#scriptString (readonly)

Returns script code Iso15924.

Returns:

  • (String)

    script code Iso15924



19
20
21
# File 'lib/iso_bib_item/iso_localized_title.rb', line 19

def script
  @script
end

#title_introString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/iso_bib_item/iso_localized_title.rb', line 7

def title_intro
  @title_intro
end

#title_mainString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/iso_bib_item/iso_localized_title.rb', line 10

def title_main
  @title_main
end

#title_partString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/iso_bib_item/iso_localized_title.rb', line 13

def title_part
  @title_part
end

Instance Method Details

#remove_partObject



37
38
39
# File 'lib/iso_bib_item/iso_localized_title.rb', line 37

def remove_part
  @title_part = nil
end

#to_sString

Returns:

  • (String)


42
43
44
45
46
47
# File 'lib/iso_bib_item/iso_localized_title.rb', line 42

def to_s
  ret = @title_main
  ret = "#{@title_intro} -- #{ret}" if @title_intro && !@title_intro.empty?
  ret = "#{ret} -- #{@title_part}" if @title_part && !@title_part.empty?
  ret
end

#to_xml(builder) ⇒ Object



49
50
51
52
53
# File 'lib/iso_bib_item/iso_localized_title.rb', line 49

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