Sha256: 587f7809845da040cb6ede6eb6cd029eeab62c773909296fefea81eec22f1457

Contents?: true

Size: 707 Bytes

Versions: 12

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

12 entries across 12 versions & 1 rubygems

Version Path
govuk_tech_docs-2.3.0 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.2.2 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.2.1 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.2.0 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.1.1 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.1.0 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.13 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.12 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.11 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.10 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.9 lib/govuk_tech_docs/table_of_contents/heading.rb
govuk_tech_docs-2.0.8 lib/govuk_tech_docs/table_of_contents/heading.rb