Class: Metanorma::Iso::Sts::Transformer::SectionTransformer

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

Constant Summary collapse

SEC_TYPE_MAP =
{
  "intro" => "intro",
  "scope" => "scope",
  "overview" => "scope",
}.freeze

Instance Method Summary collapse

Instance Method Details

#transform(clause) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metanorma/iso/sts/transformer/section_transformer.rb', line 13

def transform(clause)
  build_ordered(::Sts::IsoSts::Sec) do |sec|
    sec.id = id_for(clause)
    sec.sec_type = sec_type_for(clause)

    label_text = label_for(clause)
    sec.label = ::Sts::IsoSts::Label.new(content: [label_text]) if label_text

    if title_for(clause)
      sec.title transform_title(title_for(clause))
    end

    dispatch_content(clause, sec)
  end
end

#transform_abstract(abstract) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/metanorma/iso/sts/transformer/section_transformer.rb', line 39

def transform_abstract(abstract)
  build_ordered(::Sts::IsoSts::Sec) do |sec|
    sec.id = "sec_abstract"
    sec.sec_type = "abstract"
    sec.title transform_title(abstract.title) if abstract.title

    dispatch_content(abstract, sec)
  end
end

#transform_annex(annex) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/metanorma/iso/sts/transformer/section_transformer.rb', line 59

def transform_annex(annex)
  build_ordered(::Sts::IsoSts::Sec) do |sec|
    sec.id = id_for(annex)

    if annex.number && !annex.number.empty?
      sec.label = ::Sts::IsoSts::Label.new(content: ["Annex #{annex.number}"])
    end

    sec.title transform_title(annex.title) if annex.title

    dispatch_content(annex, sec, skip_title: true)
  end
end

#transform_foreword(foreword) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/metanorma/iso/sts/transformer/section_transformer.rb', line 29

def transform_foreword(foreword)
  build_ordered(::Sts::IsoSts::Sec) do |sec|
    sec.id = "sec_foreword"
    sec.sec_type = "foreword"
    sec.title transform_title(foreword.title) if foreword.title

    dispatch_content(foreword, sec, skip_title: true)
  end
end

#transform_introduction(intro) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/metanorma/iso/sts/transformer/section_transformer.rb', line 49

def transform_introduction(intro)
  build_ordered(::Sts::IsoSts::Sec) do |sec|
    sec.id = "sec_intro"
    sec.sec_type = "intro"
    sec.title transform_title(intro.title) if intro.title

    dispatch_content(intro, sec, skip_title: true)
  end
end