Class: GovukNavigationHelpers::TaxonBreadcrumbs
- Inherits:
-
Object
- Object
- GovukNavigationHelpers::TaxonBreadcrumbs
- Defined in:
- lib/govuk_navigation_helpers/taxon_breadcrumbs.rb
Instance Method Summary collapse
- #breadcrumbs ⇒ Object
-
#initialize(content_item) ⇒ TaxonBreadcrumbs
constructor
A new instance of TaxonBreadcrumbs.
Constructor Details
#initialize(content_item) ⇒ TaxonBreadcrumbs
Returns a new instance of TaxonBreadcrumbs.
3 4 5 |
# File 'lib/govuk_navigation_helpers/taxon_breadcrumbs.rb', line 3 def initialize(content_item) @content_item = ContentItem.new(content_item) end |
Instance Method Details
#breadcrumbs ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/govuk_navigation_helpers/taxon_breadcrumbs.rb', line 7 def ordered_parents = all_parents.map.with_index do |parent, index| { title: parent.title, url: parent.base_path, is_page_parent: index.zero? } end ordered_parents << { title: "Home", url: "/", is_page_parent: ordered_parents.empty? } { breadcrumbs: ordered_parents.reverse } end |