Sha256: 9bfea007051b2b88000b5371f4e59bbbb2e81a0b4a93f62ecf64baf6b27b1142

Contents?: true

Size: 874 Bytes

Versions: 4

Compression:

Stored size: 874 Bytes

Contents

module GovukPublishingComponents
  module Presenters
    class DevolvedNationsHelper
      attr_reader :national_applicability

      def initialize(local_assigns)
        @national_applicability = local_assigns[:national_applicability]
      end

      def applicable_nations_title_text
        @national_applicability
          .select { |_, v| v[:applicable] == true }
          .map { |k, _| I18n.t("components.devolved_nations.#{k}") }
          .sort
          .to_sentence(
            two_words_connector: I18n.t("components.devolved_nations.connectors.two_words"),
            last_word_connector: I18n.t("components.devolved_nations.connectors.last_word"),
          )
      end

      def nations_with_urls
        @national_applicability
          .select do |_, v|
            v[:alternative_url]
            .present?
          end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_publishing_components-27.6.0 lib/govuk_publishing_components/presenters/devolved_nations_helper.rb
govuk_publishing_components-27.5.0 lib/govuk_publishing_components/presenters/devolved_nations_helper.rb
govuk_publishing_components-27.4.0 lib/govuk_publishing_components/presenters/devolved_nations_helper.rb
govuk_publishing_components-27.3.1 lib/govuk_publishing_components/presenters/devolved_nations_helper.rb