Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
module AudioConfirmations
|
||||
class AudioConfirmationPresenter
|
||||
def present(audio_confirmation)
|
||||
AudioConfirmationData.new(
|
||||
source_file_name: audio_confirmation.source_file_name,
|
||||
presented_source_file_name: audio_confirmation.presented_source_file_name,
|
||||
timecode_in: audio_confirmation.timecode_in,
|
||||
should_toggle_checkmark: toggle_checkmark?(audio_confirmation),
|
||||
is_valid: audio_confirmation.valid?,
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def toggle_checkmark?(audio_confirmation)
|
||||
audio_confirmation.source_file_name.present? && audio_confirmation.timecode_in.present?
|
||||
end
|
||||
|
||||
class AudioConfirmationData < Struct.new(
|
||||
:source_file_name,
|
||||
:presented_source_file_name,
|
||||
:timecode_in,
|
||||
:should_toggle_checkmark,
|
||||
:is_valid,
|
||||
keyword_init: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
module AudioConfirmations
|
||||
class AudioConfirmationsPresenter
|
||||
def present(audio_confirmations)
|
||||
AudioConfirmationsData.new(
|
||||
audio_confirmations: sort(audio_confirmations),
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sort(audio_confirmations)
|
||||
audio_confirmations.sort_by(&:appears_at)
|
||||
end
|
||||
|
||||
class AudioConfirmationsData < Struct.new(
|
||||
:audio_confirmations,
|
||||
keyword_init: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user