Module: FactoryBotHelpers::ContentVersion

Extended by:
ContentVersion
Included in:
ContentVersion
Defined in:
lib/ecfr/testing/factory_bot_helpers/content_version.rb

Instance Method Summary collapse

Instance Method Details

#headings(attributes) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ecfr/testing/factory_bot_helpers/content_version.rb', line 19

def headings(attributes)
  default_headings = {
    title: "Energy",
    subtitle: "Other Regulations Relating to Nuclear Power",
    chapter: "Nuclear Regulatory Commission",
    part: "Agency Rules of Practice and Procedure",
    subpart: "Procedure for Imposing Requirements",
    subject_group: "Serious Civil Penalties",
    section: "Civil penalties",
    appendix: "Possibilities, Procedures and Probabilities"
  }

  headings = attributes[:hierarchy].compact.each_with_object({}) do |attr, hsh|
    hsh[attr[0]] = default_headings[attr[0]]
  end

  headings.merge(attributes[:headings])
end

#hierarchy_headings(attributes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ecfr/testing/factory_bot_helpers/content_version.rb', line 5

def hierarchy_headings(attributes)
  headings = attributes[:hierarchy].compact.each_with_object({}) do |attr, hsh|
    hsh[attr[0]] = if attr[0] == :section
      "ยง #{attr[1]}"
    elsif attr[0] == :appendix
      attr[1]
    else
      [attr[0].to_s.capitalize, attr[1]].join(" ")
    end
  end

  headings.merge(attributes[:hierarchy_headings])
end