Module: IsoDoc::IEEE::Init

Included in:
HtmlConvert, PresentationXMLConvert, WordConvert
Defined in:
lib/isodoc/ieee/init.rb

Instance Method Summary collapse

Instance Method Details

#fileloc(loc) ⇒ Object



24
25
26
# File 'lib/isodoc/ieee/init.rb', line 24

def fileloc(loc)
  File.join(File.dirname(__FILE__), loc)
end

#i18n_init(lang, script, locale, i18nyaml = nil) ⇒ Object



19
20
21
22
# File 'lib/isodoc/ieee/init.rb', line 19

def i18n_init(lang, script, locale, i18nyaml = nil)
  @i18n = I18n.new(lang, script, locale: locale,
                                 i18nyaml: i18nyaml || @i18nyaml)
end

#metadata_init(lang, script, locale, i18n) ⇒ Object



9
10
11
# File 'lib/isodoc/ieee/init.rb', line 9

def (lang, script, locale, i18n)
  @meta = Metadata.new(lang, script, locale, i18n)
end

#std_docid_sdo(text) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/isodoc/ieee/init.rb', line 56

def std_docid_sdo(text)
  found = false
  text.split(%r{([\p{Zs}|/]+)}).reverse.map do |x|
    if /[A-Za-z]/.match?(x)
      k = if found || agency?(x) then "std_publisher"
          else "std_documentType"
          end
      found = true
      "<span class='#{k}'>#{x}</span>"
    else x end
  end.reverse.join
end

#std_docid_semantic(id) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/isodoc/ieee/init.rb', line 28

def std_docid_semantic(id)
  id.nil? and return nil
  ret = Nokogiri::XML.fragment(id)
  ret.traverse do |x|
    x.text? or next
    x.replace(std_docid_semantic1(x.text))
  end
  to_xml(ret)
end

#std_docid_semantic1(id) ⇒ Object



38
39
40
41
42
# File 'lib/isodoc/ieee/init.rb', line 38

def std_docid_semantic1(id)
  ids = id.split(/\p{Zs}/)
  agency?(ids[0].sub(/\/.*$/, "")) or return id
  std_docid_semantic_full(id)
end

#std_docid_semantic_full(ident) ⇒ Object

AGENCY+ TYPE NUMBER YEAR



45
46
47
48
49
50
51
52
53
54
# File 'lib/isodoc/ieee/init.rb', line 45

def std_docid_semantic_full(ident)
  m = ident.match(%r{(?<text>[^0-9]+\p{Zs})
                  (?<num>[0-9]+)
                  (?:[:](?<yr>(?:19|20)\d\d))?}x)
  m or return ident
  ret = std_docid_sdo(m[:text]) +
    "<span class='std_docNumber'>#{m[:num]}</span>"
  m[:yr] and ret += ":<span class='std_year'>#{m[:yr]}</span>"
  ret
end

#xref_init(lang, script, _klass, i18n, options) ⇒ Object



13
14
15
16
17
# File 'lib/isodoc/ieee/init.rb', line 13

def xref_init(lang, script, _klass, i18n, options)
  html = HtmlConvert.new(language: lang, script: script)
  options = options.merge(hierarchicalassets: @hierarchical_assets)
  @xrefs = Xref.new(lang, script, html, i18n, options)
end