Sha256: 73d3fc274c1b8ea9f4f3aeca71c6c52bbb3af04a980a536109313133627b4731

Contents?: true

Size: 898 Bytes

Versions: 13

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true
module ThinkFeelDoEngine
  module LessonEvent
    # Creates a presenter for the logic of the completion data partial
    class CompletionDataPresenter
      attr_reader :event, :lesson_module

      def initialize(event:, lesson_module:)
        @event = event
        @lesson_module = lesson_module
      end

      def last_page_number_opened
        event[:last_page_number_opened]
      end

      def last_page_opened_at
        DateTime.iso8601(event[:last_page_opened_at])
      end

      def page_headers
        event[:page_headers].try do |page_headers|
          page_headers[2]
        end
      end

      def pretty_title
        lesson.pretty_title
      end

      def selected_at
        DateTime.iso8601(event[:lesson_selected_at])
      end

      private

      def lesson
        lesson_module.find(event[:lesson_id])
      end
    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/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.8 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.7 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.6 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.5 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.4 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.2 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.1 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.22.0 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.21.2 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.21.1 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.21.0 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb
think_feel_do_engine-3.20.1 app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb