Sha256: 5994e387241b8243f0ec5477f94f204f42c171883764296caed28e590d599adb

Contents?: true

Size: 707 Bytes

Versions: 27

Compression:

Stored size: 707 Bytes

Contents

module GovukTechDocs
  module TableOfContents
    class Heading
      def initialize(element_name:, text:, attributes:, page_url: '')
        @element_name = element_name
        @text = text
        @attributes = attributes
        @page_url = page_url
      end

      def size
        @element_name.scan(/h(\d)/) && $1 && Integer($1)
      end

      def href
        @page_url + '#' + @attributes['id']
      end

      def title
        @text
      end

      def ==(other)
        @element_name == other.instance_variable_get("@element_name") &&
          @text == other.instance_variable_get("@text") &&
          @attributes == other.instance_variable_get("@attributes")
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
govuk_tech_docs-2.0.7 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.6 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.5 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.4 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.3 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.2 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.1 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.0.pre.test.pre.release.pre.525 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.0.pre.test.pre.release.pre.524 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.0.test.pre.release.521 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.0 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-1.9.0.pre.rc2 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-1.9.0.pre.gfe lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-1.8.3 lib/govuk_tech_docs/table_of_contents/heading.rb
dss_tech_docs-0.1.2 lib/govuk_tech_docs/table_of_contents/heading.rb
dss_tech_docs-0.1.1 lib/govuk_tech_docs/table_of_contents/heading.rb
dss_tech_docs-0.1.0 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-1.8.2 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-1.8.1 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-1.8.0 lib/govuk_tech_docs/table_of_contents/heading.rb