Class: Metanorma::Iso::Sts::Transformer::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/iso/sts/transformer/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_document) ⇒ Context

Returns a new instance of Context.



9
10
11
12
13
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 9

def initialize(source_document)
  @source_document = source_document
  @id_generator = Transformer::IdGenerator.new(self)
  @footnote_collector = Transformer::FootnoteCollector.new
end

Instance Attribute Details

#footnote_collectorObject (readonly)

Returns the value of attribute footnote_collector.



7
8
9
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 7

def footnote_collector
  @footnote_collector
end

#id_generatorObject (readonly)

Returns the value of attribute id_generator.



7
8
9
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 7

def id_generator
  @id_generator
end

#source_documentObject (readonly)

Returns the value of attribute source_document.



7
8
9
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 7

def source_document
  @source_document
end

Instance Method Details

#bibitem_lookupObject



40
41
42
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 40

def bibitem_lookup
  @bibitem_lookup ||= build_bibitem_lookup
end

#doctypeObject



35
36
37
38
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 35

def doctype
  bibdata = @source_document.bibdata
  bibdata&.ext&.doctype
end

#languageObject



15
16
17
18
19
20
21
22
23
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 15

def language
  return nil unless @source_document

  bibdata = @source_document.bibdata
  return nil unless bibdata

  lang = bibdata.language
  lang.is_a?(Array) ? lang.first : lang
end

#scriptObject



25
26
27
28
29
30
31
32
33
# File 'lib/metanorma/iso/sts/transformer/context.rb', line 25

def script
  return nil unless @source_document

  bibdata = @source_document.bibdata
  return nil unless bibdata

  scr = bibdata.script
  scr.is_a?(Array) ? scr.first : scr
end