Class: GovukPublishingComponents::Presenters::Breadcrumb
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::Breadcrumb
- Extended by:
- Forwardable
- Defined in:
- lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb
Instance Method Summary collapse
-
#initialize(crumb, index) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
- #is_link? ⇒ Boolean
- #item_list_element ⇒ Object
- #path ⇒ Object
- #tracking_data(breadcrumbs_length) ⇒ Object
Constructor Details
#initialize(crumb, index) ⇒ Breadcrumb
Returns a new instance of Breadcrumb.
31 32 33 34 |
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 31 def initialize(crumb, index) @crumb = crumb @index = index + 1 end |
Instance Method Details
#is_link? ⇒ Boolean
44 45 46 |
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 44 def is_link? crumb[:url].present? end |
#item_list_element ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 36 def item_list_element { "@type" => "ListItem", "position" => index, "item" => list_item_item, } end |
#path ⇒ Object
48 49 50 |
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 48 def path crumb[:url] end |
#tracking_data(breadcrumbs_length) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 52 def tracking_data() { ga4_link: { event_name: "navigation", type: "breadcrumb", index_link: index.to_s, index_total: .to_s, }, } end |