require 'ostruct'
module DebateOutcomeHelper - DebateOutcomeHelper has no descriptive comment
DEBATE_OUTCOME_URLS = %i[video_url transcript_url debate_pack_url]
def debate_outcome_image(debate_outcome)
sources = ['1x', '2x'].map { |size| "#{debate_outcome.commons_image.url(size)} #{size}" } -
-
image_tag(debate_outcome.commons_image.url('2x'), 'aria-hidden': '', srcset: sources.join(', ')) -
-
end
def debate_outcome_links?(debate_outcome) - DebateOutcomeHelper#debate_outcome_links? doesn't depend on instance state (maybe move it to another class?)
DEBATE_OUTCOME_URLS.any? { |url| debate_outcome.public_send(:"#{url}?") }
end
def debate_outcome_links(debate_outcome) - DebateOutcomeHelper#debate_outcome_links doesn't depend on instance state (maybe move it to another class?)
DEBATE_OUTCOME_URLS.map do |url|
if debate_outcome.public_send(:"#{url}?")
OpenStruct.new(
title: I18n.t(url, scope: :"petitions.debate_outcomes.link_titles"),
url: debate_outcome.public_send(:"#{url}")
)
end
end.compact
end
end