Module: CloudinarySubtitlesEmbedder

Defined in:
lib/cloudinary_subtitles_embedder.rb,
lib/cloudinary_subtitles_embedder/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.add_subtitles_to_video(video_public_id, subtitles, cloud_name = 'candidate-evaluation', display_options = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cloudinary_subtitles_embedder.rb', line 4

def self.add_subtitles_to_video(
  video_public_id,
  subtitles,
  cloud_name = 'candidate-evaluation',
  display_options = nil
)
  to_sub = Proc.new do |s|
    SubtitleLine.new(s, display_options)
  end
  prefix = "https://res.cloudinary.com/#{cloud_name}/video/upload"
  subtitle_url = subtitles
                   .map{|s| to_sub.call(s)}
                   .map(&:to_s)
                   .reduce(&:+)
  prefix + subtitle_url + '/' + video_public_id
end