class GovukTechDocs::TableOfContents::Heading

Public Class Methods

new(element_name:, text:, attributes:, page_url: '') click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading.rb, line 4
def initialize(element_name:, text:, attributes:, page_url: '')
  @element_name = element_name
  @text = text
  @attributes = attributes
  @page_url = page_url
end

Public Instance Methods

==(other) click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading.rb, line 23
def ==(other)
  @element_name == other.instance_variable_get("@element_name") &&
    @text == other.instance_variable_get("@text") &&
    @attributes == other.instance_variable_get("@attributes")
end
href() click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading.rb, line 15
def href
  @page_url + '#' + @attributes['id']
end
size() click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading.rb, line 11
def size
  @element_name.scan(/h(\d)/) && $1 && Integer($1)
end
title() click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading.rb, line 19
def title
  @text
end