Module: ShiftSubtitles::Process

Defined in:
lib/shift_subtitles/process.rb

Class Method Summary collapse

Class Method Details

.create_and_populate_output_file(output_file_name, subtitles) ⇒ Object



12
13
14
15
16
# File 'lib/shift_subtitles/process.rb', line 12

def self.create_and_populate_output_file output_file_name, subtitles
  ShiftSubtitles::FileHelper.operation_with_validation('output', output_file_name) do 
    File.open(output_file_name, 'w') { |file| file << subtitles.formatted_subtitles_for_file }
  end
end

.shift_subtitles(options) ⇒ Object



5
6
7
8
9
10
# File 'lib/shift_subtitles/process.rb', line 5

def self.shift_subtitles options
  operation = ShiftSubtitles::Operation.new(options[:action], options[:time])
  subtitles = ShiftSubtitles::Subtitles.new(options[:input])
  subtitles.update_subtitles(operation.seconds_difference)
  create_and_populate_output_file(options[:output], subtitles)
end