Class: IsoDoc::Mpfd::Metadata

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

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, labels) ⇒ Metadata

Returns a new instance of Metadata.



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

def initialize(lang, script, labels)
  super
          here = File.dirname(__FILE__)
  set(:logo, File.expand_path(File.join(here, "html", "[email protected]")))
end

Instance Method Details

#author(isoxml, _out) ⇒ Object



24
25
26
27
# File 'lib/isodoc/mpfd/metadata.rb', line 24

def author(isoxml, _out)
  publisher = isoxml.at(ns("//bibdata/contributor/organization/name"))
  set(:publisher, publisher.text) if publisher
end

#docid(isoxml, _out) ⇒ Object



29
30
31
32
# File 'lib/isodoc/mpfd/metadata.rb', line 29

def docid(isoxml, _out)
  docnumber = isoxml.at(ns("//bibdata/docidentifier"))
  set(:docnumber, docnumber&.text)
end

#doctype(isoxml, _out) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/isodoc/mpfd/metadata.rb', line 34

def doctype(isoxml, _out)
  b = isoxml&.at(ns("//bibdata/ext/doctype"))&.text || return
  return unless b
  t = b.split(/[- ]/).
    map{ |w| w.capitalize unless w == "MPF" }.join(" ")
  set(:doctype, t)
end

#monthyr(isodate) ⇒ Object



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

def monthyr(isodate)
  date = DateTime.parse(isodate)
  date.strftime('%-d %B %Y')    #=> "Sun 04 Feb 2001"
rescue
  # invalid dates get thrown
  isodate
end

#stage_abbr(status) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/isodoc/mpfd/metadata.rb', line 42

def stage_abbr(status)
  case status
  when "working-draft" then "wd"
  when "committee-draft" then "cd"
  when "draft-standard" then "d"
  else
    ""
  end
end

#subtitle(_isoxml, _out) ⇒ Object



20
21
22
# File 'lib/isodoc/mpfd/metadata.rb', line 20

def subtitle(_isoxml, _out)
  nil
end

#title(isoxml, _out) ⇒ Object



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

def title(isoxml, _out)
  main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text
  set(:doctitle, main)
end

#version(isoxml, _out) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/isodoc/mpfd/metadata.rb', line 52

def version(isoxml, _out)
  super
  edition = isoxml.at(ns("//version/edition"))
  if edition
    set(
      :edition,
      edition.text.to_i.localize.
        to_rbnf_s("SpelloutRules", "spellout-ordinal").
        split(/(\W)/).map(&:capitalize).join
    )
  end
end