Class: GovukTechDocs::TableOfContents::HeadingsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_tech_docs/table_of_contents/headings_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(html, url) ⇒ HeadingsBuilder

Returns a new instance of HeadingsBuilder.



4
5
6
7
# File 'lib/govuk_tech_docs/table_of_contents/headings_builder.rb', line 4

def initialize(html, url)
  @html = html
  @url = url
end

Instance Method Details

#headingsObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/govuk_tech_docs/table_of_contents/headings_builder.rb', line 9

def headings
  heading_elements.map do |element|
    Heading.new(
      element_name: element.node_name,
      text: element.content,
      attributes: convert_nokogiri_attr_objects_to_hashes(element.attributes),
      page_url: @url,
    )
  end
end