Class: SplitCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- SplitCommand
- Defined in:
- lib/commands/split_command.rb
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/commands/split_command.rb', line 14 def execute file = File.open(path) srt = SRT::File.parse(file) results = srt.split(every: interval, renumber: renumber?) progress = ProgressBar.create(title: 'Saving subtitle', starting_at: 0, total: results.length) results.each_with_index do |line, index| File.write("#{output_dir}/#{prefix}-#{'%03d' % (starting_index.to_i+index)}.srt", line.to_s) progress.increment end end |