Sha256: 24e919ab4dd4e56453d3d2f3c108d385884b131424bacaff0651e5529a41bee1

Contents?: true

Size: 717 Bytes

Versions: 13

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true
module ThinkFeelDoEngine
  # Simplifies the logic of the conditions to display a thought viz
  class HarmfulThoughtVizPresenter
    TOO_FEW_THOUGHTS = 2

    attr_reader :pattern_ids

    def initialize(harmful_thought_ids)
      @pattern_ids = harmful_thought_ids
    end

    def display_viz?
      uniq_pattern_ids
        .select { |id| compacted_pattern_ids.count(id) > TOO_FEW_THOUGHTS }
        .present?
    end

    private

    def compacted_pattern_ids
      @compacted_pattern_ids ||= pattern_ids
                                 .compact
    end

    def uniq_pattern_ids
      @uniq_pattern_ids ||= compacted_pattern_ids
                            .uniq
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
think_feel_do_engine-3.22.9 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.8 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.7 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.6 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.5 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.4 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.2 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.1 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.22.0 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.21.2 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.21.1 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.21.0 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.20.1 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb