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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 52 def tracking_data() data = { track_category: "breadcrumbClicked", track_action: index, track_label: path, track_options: { dimension28: .to_s, dimension29: crumb[:title], }, ga4_link: { event_name: "navigation", type: "breadcrumb", index_link: index.to_s, index_total: .to_s, }, } is_homepage = crumb[:url] == "/" if is_homepage data[:track_category] = "homeLinkClicked" data[:track_action] = "homeBreadcrumb" data[:track_label] = "" data[:track_options] = "{}" end data end |