Sha256: 8d94699ac5472c09497137f3cbce817381ba0d84c5c8c6b765d72b232900bd01

Contents?: true

Size: 687 Bytes

Versions: 55

Compression:

Stored size: 687 Bytes

Contents

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

55 entries across 55 versions & 1 rubygems

Version Path
think_feel_do_engine-3.19.9 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.8 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.7 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.6 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.5 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.4 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.3 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.2 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.1 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.19.0 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.18.0 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.17.2 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.17.1 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.17.0 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.16.3 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.16.2 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.16.1 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.15.7 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.16.0 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb
think_feel_do_engine-3.15.6 app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb