Class: GovukPublishingComponents::Presenters::ImageCardHelper
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::ImageCardHelper
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/govuk_publishing_components/presenters/image_card_helper.rb
Instance Attribute Summary collapse
-
#extra_links ⇒ Object
readonly
Returns the value of attribute extra_links.
-
#extra_links_no_indent ⇒ Object
readonly
Returns the value of attribute extra_links_no_indent.
-
#heading_text ⇒ Object
readonly
Returns the value of attribute heading_text.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#href_data_attributes ⇒ Object
readonly
Returns the value of attribute href_data_attributes.
-
#large ⇒ Object
readonly
Returns the value of attribute large.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #context ⇒ Object
- #description ⇒ Object
- #image ⇒ Object
-
#initialize(local_assigns) ⇒ ImageCardHelper
constructor
A new instance of ImageCardHelper.
- #is_tracking? ⇒ Boolean
Constructor Details
#initialize(local_assigns) ⇒ ImageCardHelper
Returns a new instance of ImageCardHelper.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 9 def initialize(local_assigns) @href = local_assigns[:href] @href_data_attributes = local_assigns[:href_data_attributes] @extra_links = local_assigns[:extra_links] || [] @image_src = local_assigns[:image_src] @image_alt = local_assigns[:image_alt] || "" @context = local_assigns[:context] @description = local_assigns[:description] @large = local_assigns[:large] @heading_text = local_assigns[:heading_text] @extra_links_no_indent = local_assigns[:extra_links_no_indent] @metadata = local_assigns[:metadata] end |
Instance Attribute Details
#extra_links ⇒ Object (readonly)
Returns the value of attribute extra_links.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def extra_links @extra_links end |
#extra_links_no_indent ⇒ Object (readonly)
Returns the value of attribute extra_links_no_indent.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def extra_links_no_indent @extra_links_no_indent end |
#heading_text ⇒ Object (readonly)
Returns the value of attribute heading_text.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def heading_text @heading_text end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def href @href end |
#href_data_attributes ⇒ Object (readonly)
Returns the value of attribute href_data_attributes.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def href_data_attributes @href_data_attributes end |
#large ⇒ Object (readonly)
Returns the value of attribute large.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def large @large end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 7 def @metadata end |
Instance Method Details
#context ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 42 def context return unless @context content_tag(:p, class: 'gem-c-image-card__context') do if @context[:date] date = content_tag(:time, l(@context[:date], format: '%e %B %Y'), datetime: @context[:date].iso8601) dash = content_tag(:span, ' — ', 'aria-hidden': true) if @context[:text] date.concat(dash).concat(@context[:text]) else date end else @context[:text] end end end |
#description ⇒ Object
61 62 63 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 61 def description content_tag(:div, @description, class: "gem-c-image-card__description") if @description end |
#image ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 34 def image if @image_src content_tag(:figure, class: "gem-c-image-card__image-wrapper") do image_tag(@image_src, class: "gem-c-image-card__image", alt: @image_alt) end end end |
#is_tracking? ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/govuk_publishing_components/presenters/image_card_helper.rb', line 23 def is_tracking? return true if @href_data_attributes if @extra_links @extra_links.each do |link| return true if link[:data_attributes] end end false end |