Class: IsoDoc::ITU::Metadata

Inherits:
Metadata
  • Object
show all
Defined in:
lib/isodoc/itu/metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, labels) ⇒ Metadata

Returns a new instance of Metadata.



7
8
9
10
11
12
13
14
15
16
# File 'lib/isodoc/itu/metadata.rb', line 7

def initialize(lang, script, labels)
  super
  here = File.dirname(__FILE__)
  set(:logo_html,
      File.expand_path(File.join(here, "html", "International_Telecommunication_Union_Logo.svg")))
  set(:logo_comb,
      File.expand_path(File.join(here, "html", "itu-document-comb.png")))
  set(:logo_word,
      File.expand_path(File.join(here, "html", "International_Telecommunication_Union_Logo.svg")))
end

Instance Method Details

#author(isoxml, _out) ⇒ Object



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

def author(isoxml, _out)
  bureau = isoxml.at(ns("//bibdata/ext/editorialgroup/bureau"))
  set(:bureau, bureau.text) if bureau
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
  set(:tc, tc.text) if tc
  super
end

#bibdate(isoxml, _out) ⇒ Object



60
61
62
63
# File 'lib/isodoc/itu/metadata.rb', line 60

def bibdate(isoxml, _out)
  pubdate = isoxml.xpath(ns("//bibdata/date[@type = 'published']"))
  pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
end

#docid(isoxml, _out) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/isodoc/itu/metadata.rb', line 47

def docid(isoxml, _out)
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ITU']"))
  set(:docnumber, dn&.text)
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/annexid"))
  oblig = isoxml&.at(ns("//annex/@obligation"))&.text
  lbl = oblig == "informative" ? @labels["appendix"] : @labels["annex"]
  dn and set(:annexid, IsoDoc::Function::I18n::l10n("#{lbl} #{dn&.text}"))
end

#doctype(isoxml, _out) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/isodoc/itu/metadata.rb', line 76

def doctype(isoxml, _out)
  d = isoxml&.at(ns("//bibdata/ext/doctype"))&.text
  set(:doctype_original, d)
  if d == "recommendation-annex"
    set(:doctype, "Recommendation")
  else
    super
  end
end

#ip_notice_received(isoxml, _out) ⇒ Object



86
87
88
89
90
# File 'lib/isodoc/itu/metadata.rb', line 86

def ip_notice_received(isoxml, _out)
  received = isoxml.at(ns("//bibdata/ext/ip-notice-received"))&.text ||
    "false"
  set(:ip_notice_received, received)
end

#keywords(isoxml, _out) ⇒ Object



71
72
73
74
# File 'lib/isodoc/itu/metadata.rb', line 71

def keywords(isoxml, _out)
  super
  set(:keywords, get[:keywords].sort)
end

#monthyr(isodate) ⇒ Object



65
66
67
68
69
# File 'lib/isodoc/itu/metadata.rb', line 65

def monthyr(isodate)
  m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
  return isodate unless m && m[:yr] && m[:mo]
  return "#{m[:mo]}/#{m[:yr]}"
end

#subtitle(_isoxml, _out) ⇒ Object



35
36
37
# File 'lib/isodoc/itu/metadata.rb', line 35

def subtitle(_isoxml, _out)
  nil
end

#title(isoxml, _out) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/isodoc/itu/metadata.rb', line 18

def title(isoxml, _out)
  main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}'][@type = 'main']"))&.text
  set(:doctitle, main)
  main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}'][@type = 'subtitle']"))&.text
  set(:docsubtitle, main)
  series = isoxml&.at(ns("//bibdata/series[@type='main']/title"))&.text
  set(:series, series)
  series1 =
    isoxml&.at(ns("//bibdata/series[@type='secondary']/title"))&.text
  set(:series1, series1)
  series2 =
    isoxml&.at(ns("//bibdata/series[@type='tertiary']/title"))&.text
  set(:series2, series2)
  annext = isoxml&.at(ns("//bibdata/title[@type='annex']"))&.text
  set(:annextitle, annext)
end

#unpublished(status) ⇒ Object



56
57
58
# File 'lib/isodoc/itu/metadata.rb', line 56

def unpublished(status)
  %w(in-force-prepublished draft).include? status.downcase
end