Class: IsoDoc::Iho::Metadata

Inherits:
Generic::Metadata
  • Object
show all
Extended by:
ClassUtils
Includes:
Function::Utils
Defined in:
lib/isodoc/iho/metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, locale, i18n, fonts_options = {}) ⇒ Metadata

Returns a new instance of Metadata.



10
11
12
13
# File 'lib/isodoc/iho/metadata.rb', line 10

def initialize(lang, script, locale, i18n, fonts_options = {})
  super
  @tempfile_cache = []
end

Instance Method Details

#configurationObject



15
16
17
# File 'lib/isodoc/iho/metadata.rb', line 15

def configuration
  Metanorma::Iho.configuration
end

#images(xml, out) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/isodoc/iho/metadata.rb', line 48

def images(xml, out)
  super
  images_logo_xpaths.each do |k, v|
    i = xml.at(ns(v))
    set(k, i ? to_xml(i.at("./*[local-name() = 'svg']"))&.strip : nil)
    src = i&.at(ns("./emf/@src"))
    src and set("#{k}_emf".to_sym, save_dataimage(src.text))
  end
end

#images_logo_xpathsObject



38
39
40
41
42
43
44
45
46
# File 'lib/isodoc/iho/metadata.rb', line 38

def images_logo_xpaths
  org = "//bibdata/contributor[role/@type = 'publisher']/organization"
  {
    logo: "//#{org}/logo[@type = 'full']/image",
    logo_desc: "//#{org}/logo[@type = 'desc']/image",
    logo_mark: "//#{org}/logo[@type = 'mark']/image",
    logo_sign: "//#{org}/logo[@type = 'sign']/image",
  }
end

#series(xml, _out) ⇒ Object



19
20
21
22
23
# File 'lib/isodoc/iho/metadata.rb', line 19

def series(xml, _out)
  set(:series, xml.at(ns("//bibdata/series[@type = 'main']/title"))&.text)
  a = xml.at(ns("//bibdata/series[@type = 'main']/abbreviation"))
  a&.text and set(:seriesabbr, a.text)
end

#title(isoxml, _out) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/isodoc/iho/metadata.rb', line 30

def title(isoxml, _out)
  set(:doctitle, isoxml.at(ns("//bibdata/title[@type='main']"))
                              &.children&.to_xml || "")
  %w(main appendix annex part supplement).each do |e|
    t = title1(isoxml, e) and set("#{e}title".to_sym, t)
  end
end

#title1(xml, type) ⇒ Object



25
26
27
28
# File 'lib/isodoc/iho/metadata.rb', line 25

def title1(xml, type)
  xml.at(ns("//bibdata/title[@type='title-#{type}']"))
    &.children&.to_xml
end