Class: RelatonIsoBib::HashConverter

Inherits:
RelatonBib::HashConverter
  • Object
show all
Defined in:
lib/relaton_iso_bib/hash_converter.rb

Class Method Summary collapse

Class Method Details

.hash_to_bib(args, nested = false) ⇒ Hash

Parameters:

  • args (Hash)
  • nested (TrueClass, FalseClass) (defaults to: false)

Returns:

  • (Hash)


8
9
10
11
12
13
14
15
16
# File 'lib/relaton_iso_bib/hash_converter.rb', line 8

def hash_to_bib(args, nested = false)
  ret = super
  return if ret.nil?

  editorialgroup_hash_to_bib(ret)
  ics_hash_to_bib(ret)
  structuredidentifier_hash_to_bib(ret)
  ret
end

.split_title(content, lang = "en", script = "Latn") ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/relaton_iso_bib/hash_converter.rb', line 18

def split_title(content, lang = "en", script = "Latn")
  titles = content&.split(/ (?:--|—|–) /)
  case titles&.size
  when nil, 0
    intro, main, part = nil, "", nil
  when 1
    intro, main, part = nil, titles[0], nil
  when 2
    if /^(Part|Partie) \d+:/ =~ titles[1]
      intro, main, part = nil, titles[0], titles[1]
    else
      intro, main, part = titles[0], titles[1], nil
    end
  when 3
    intro, main, part = titles[0], titles[1], titles[2]
  else
    intro, main, part = titles[0], titles[1], titles[2..-1]&.join(" -- ")
  end
  {
    title_intro: intro,
    title_main: main,
    title_part: part,
    language: lang,
    script: script,
  }
end